es6 looping over object in javascript code example
Example 1: js loop over object
const object = {a: 1, b: 2, c: 3};
for (const property in object) {
console.log(`${property}: ${object[property]}`);
}
Example 2: es6 loop through object
for (var [key, value] of phoneBookMap) {
console.log(key + "'s phone number is: " + value);
}