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] ]
时间: 2024-10-17 06:24:39