📜  for in object javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:56.278000             🧑  作者: Mango

代码示例6
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;