The entries(), keys(), and values() methods

The entries() method of an array returns an iterable object that contains the key/value pairs for each index of the array. Similarly, the keys() method of an array returns an iterable object that contains keys for each of the indexes in the array.

Similarly, the values() method of an array returns an iterable object that contains values of the array. The iterable object returned by the entries() method stores the key/value pairs in the form of arrays.

The iterable object returned by these functions is not an array.

Here is an example to demonstrate this:

const arr = ['a', 'b', 'c'];const entries = arr.entries();const keys = arr.keys();const values = arr.values();console.log(...entries);console.log(...keys); ...

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.