English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript Array entries() Method

 JavaScript Array Object

The entries() method returns a new array iterator object that contains the keys at each index of the array/Pairs.

Syntax:

array.entries()
var fruits = ['Apple', 'Mango', 'Banana'];
var iter = fruits.entries();
Test and see‹/›

For each item in the original array, the new iterator object will contain an array with the index as the key and the item value as the value:

  • [0,“ Apple”]

  • [1,“Mango”]

  • [2,“Banana”]

Browser Compatibility

The numbers in the table specify the first browser version that fully supports the entry() method:

Method
entries()3828258Yes

Technical Details

Return Value:A new Array iterator object
JavaScript Version:ECMAScript 6

More Examples

The following code uses the for...of loop to print the key/Value Pair:

var fruits = ['Apple', 'Mango', 'Banana'];
var iter = fruits.entries();
for (let e of iter) {
 console.log(e);
}
Test and see‹/›

 JavaScript Array Object