html loop through object code example
Example 1: javascript loop through object
Object.entries(obj).forEach(
([key, value]) => console.log(key, value)
);
Example 2: how to loop trough an object java script
const keys = Object.keys(fruits)
for (const key of keys) {
console.log(key)
}
Example 3: javascript loop through object properties
for (var prop in obj) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
}
}
Example 4: how to loop trough an object java script
const fruits = {
apple: 28,
orange: 17,
pear: 54,
}
const values = Object.values(fruits)
console.log(values)
Example 5: going through every attributes of an object javascript
let a = {x: 200, y: 1}
let attributes = Object.keys(a)
console.log(attributes)