JS how to loop trhough each item code example
Example 1: iterate over object javascript
// Looping through arrays created from Object.keys
const keys = Object.keys(fruits)
for (const key of keys) {
console.log(key)
}
// Results:
// apple
// orange
// pear
Example 2: javascript loop through object
for (var property in object) {
if (object.hasOwnProperty(property)) {
// Do things here
}
}