var obj = { foo: 'bar', baz: 42 };
Object.keys(obj).forEach((key) => {
const el = obj[key];
console.log(
{
key: key,
value: el
}
);
});
var obj = { foo: 'bar', baz: 42 };
console.log(Object.entries(obj)); // [ ['foo', 'bar'], ['baz', 42] ]
for(const [i, val] of Object.entries(obj))
new_obj[i] = val;
for (key in object) {
console.log(key,object[key]);
}