JavaScript Array entries() Tutorial

In this section, we will learn what the entries() method is and how to use it in JavaScript.

JavaScript Arrays entries() Method

The entries() method is used to return an iterator that contains all the entries of an array.

In arrays, an entry is each element of the target array with its index number. We get each entry in a form of an array! So if we call this method, we will get a 2-dimensional array, with each element being a sub-array containing the target array’s element with its index number.

Array entries() Syntax:


Array entries() Method Parameters:

This method does not take any argument.

Array entries() Method Return Value:

The return value of this method is an iterator that contains the entries of the target array.

Example: JavaScript Array and for Loop

const arr = ["Apple","Google",,,,"Microsoft","Amazon"];
for (const [key, value] of arr.entries()){
  console.log(key, value);


0 "Apple"

1 "Google"

2 undefined

3 undefined

4 undefined

5 "Microsoft"

6 "Amazon"

Leave a Reply