const obj = { foo: 'bar', baz: 42 };
console.log(Object.entries(obj));
const obj = { 0: 'a', 1: 'b', 2: 'c' };
console.log(Object.entries(obj));
const anObj = { 100: 'a', 2: 'b', 7: 'c' };
console.log(Object.entries(anObj));
const myObj = Object.create({}, { getFoo: { value() { return this.foo; } } });
myObj.foo = 'bar';
console.log(Object.entries(myObj));
console.log(Object.entries('foo'));
console.log(Object.entries(100));
const obj = { a: 5, b: 7, c: 9 };
for (const [key, value] of Object.entries(obj)) {
console.log(`${key} ${value}`);
}
Object.entries(obj).forEach(([key, value]) => {
console.log(`${key} ${value}`);
});