JS: Object.entries

By Xah Lee. Date: . Last updated: .

(new in 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(Object.entries({ a: 3, b: 4 }));
// [ [ "a", 3 ], [ "b", 4 ] ]

JavaScript. Object Properties to Array