how to iterate through a js object

JavaScript
for (var property in object) {
  if (object.hasOwnProperty(property)) {
    // Do things here
  }
}let object = {
  x: 10,
  y: 10,
  z: 10
};
let keys = Object.keys(object);
// now 3 different ways:
  // method 1:
  key.forEach(function(key){
      let attribute = object[key];
      // do stuff
    }
  );

  //method 2:
  for(let key of keys){
    let attribute = object[key];
    // do stuff
  }

  //method 3:
  for(let i = 0; i < keys.length; i++){
    let key = keys[i];
    let attribute = object[key];
    // do stuff
  }let a = {x: 200, y: 1}
let attributes = Object.keys(a)
console.log(attributes)
//output: ["x", "y"]
Source

Also in JavaScript: