JS: Object.entries
(new in JS: ECMAScript 2017)
Object.entries(obj)
-
- Convert object to Array.
- Each property is converted to array
[key, value]
. - Only consider properties that are own, string key, and Enumerable. Others are ignored.
- Return the new array.
console.log( JSON.stringify(Object.entries({ a: 3, b: 4 })) === `[["a",3],["b",4]]`, ); // true