for loop keys in object javascript code example
Example 1: javascript looping through object
const fruits = {
apple: 28,
orange: 17,
pear: 54,
}
const values = Object.values(fruits)
console.log(values) // [28, 17, 54]
Example 2: iterate over array of object javascript and access the properties
for (let item of items) {
console.log(item); // Will display contents of the object inside the array
}