You often need to look through the properties and values of plain JavaScript objects.

Here are the common lists to extract from an object:

  • The keys of an object is the list of property names.
  • The values of an object is the list of property values.
  • The entries of an object is the list of pairs of property names and corresponding values.

Let’s consider the following JavaScript object:

const hero = {
  name: 'Batman',
  city: 'Gotham'  
};

The keys of hero are ['name', 'city']. The values are ['Batman', 'Gotham']. And the entries are [['name', 'Batman'], ['city', 'Gotham']].

Let’s see what utility functions provide JavaScript to extract the keys, values, and entries from an object.

#javascript #object

How to Access Object's Keys, Values, and Entries in JavaScript
2.05 GEEK