javascript iterate over objects easy way code example
Example 1: javascript looping through object
for (var property in object) {
if (object.hasOwnProperty(property)) {
// Do things here
}
}
Example 2: javascript looping through object
for (const [fruit, count] of entries) {
console.log(`There are ${count} ${fruit}s`)
}
// Result
// There are 28 apples
// There are 17 oranges
// There are 54 pears