This chapter describes the ECMAScript 2017 feature “Object.values/Object.entries” by Jordan Harband.
This method has the following signature:
x to an Object and returns the entries of its enumerable own string-keyed properties, in an Array:
Properties, whose keys are symbols, are ignored:
Object.entries() finally gives us a way to iterate over the properties of an object (read here why objects aren’t iterable by default):
Object.entries() also lets you set up a Map via an object. This is more concise than using an Array of 2-element Arrays, but keys can only be strings.
Object.entries()an Array and not an iterator?
Object.keys(), not, e.g.,
Object.entries()only return the enumerable own string-keyed properties?
Object.keys(). That method also ignores properties whose keys are symbols. Eventually, there may be a method
Reflect.ownEntries()that returns all own properties.
Object.values() has the following signature:
It works much like
Object.entries(), but, as its name suggests, it only returns the values of the own enumerable string-keyed properties: