Favorites

JavaScript Array.prototype.entries() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Array.prototype.entries()
JavaScript Array Instance methodThis method is supported by all modern browsers.
Updated 28th November 2026

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

const colors = ['red', 'green', 'blue'];
for (const [i, color] of colors.entries()) {
  console.log(i, color);
}
console.log([...['a', 'b'].entries()]);

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.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee