iterate through object array javascript

JavaScript
var p = {
    "p1": "value1",
    "p2": "value2",
    "p3": "value3"
};

// for-in
for (var key in p) {
    if (p.hasOwnProperty(key)) {
        console.log(key + " -> " + p[key]);
    }
}

// for-of with Object.keys()
for (var key of Object.keys(p)) {
    console.log(key + " -> " + p[key])
}

// Object.entries()
for (let [key, value] of Object.entries(p)) {
  console.log(`${key}: ${value}`);
}for (var key in array) {
    var obj = myArray[key];
    // ...
}for (let key in yourobject) {
   if (yourobject.hasOwnProperty(key)) {
      console.log(key, yourobject[key]);
   }
}

Source

Also in JavaScript: