[ES2017] Iterate over properties of an object with ES2017 Object.entries()

The Object.entries() function is an addition to the ECMAscript scpec in Es2017. This allows us to iterate through the properties of an object and read the entries as keys and objects.

const obj = { foo: 'bar', baz: 42 };
console.log(Object.entries(obj)); // [ ['foo', 'bar'], ['baz', 42] ]
原文地址:https://www.cnblogs.com/Answer1215/p/7923017.html