JavaScript Array.prototype.entries() Method
The entries() method returns an iterator of [index, element] pairs, which is handy for getting the index in a for...of loop.
Description
The entries() method returns an iterator that produces a two-element array, [index, element], for each position in the array. It is most often used with for...of and destructuring to loop over an array with its indexes.
Empty slots in sparse arrays are included with the value undefined. The related keys() and values() methods return only the indexes or only the elements.
The iterator works with iterator helpers in modern browsers, so arr.entries().filter(...) can process pairs lazily. To get an array of pairs immediately, spread it, [...arr.entries()]. Object.entries() is the related function for objects, and maps and sets have their own entries() methods.
Syntax
array.entries()Return Value
A new array iterator that yields [index, element] pairs.
Example
Browser Support
The following information will show you the current browser support for the Array.prototype.entries() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





