loop through obj javascript code example
Example 1: loop through object javascript
const fruits = {
apple: 28,
orange: 17,
pear: 54,
}
const keys = Object.keys(fruits)
console.log(keys) // [apple, orange, pear]
Example 2: javascript loop through object
var person = {"name":"bob", age:45};
for (var property in person) {
console.log(person[property]);
}