javascript loop objects code example
Example 1: javascript loop through object
Object.entries(obj).forEach(
([key, value]) => console.log(key, value)
);
Example 2: javascript loop through object
const point = {
x: 10,
y: 20,
};
for (const [axis, value] of Object.entries(point)) {
console.log(`${axis} => ${value}`);
}
/** prints:
* x => 10
* y => 20
*/