1let object = {
2 x: 10,
3 y: 10,
4 z: 10
5};
6let keys = Object.keys(object);
7// now 3 different ways:
8 // method 1:
9 key.forEach(function(key){
10 let attribute = object[key];
11 // do stuff
12 }
13 );
14
15 //method 2:
16 for(let key of keys){
17 let attribute = object[key];
18 // do stuff
19 }
20
21 //method 3:
22 for(let i = 0; i < keys.length; i++){
23 let key = keys[i];
24 let attribute = object[key];
25 // do stuff
26 }
1let a = {x: 200, y: 1}
2let attributes = Object.keys(a)
3console.log(attributes)
4//output: ["x", "y"]