Skip to content

JavaScript Array entries() | Method

  • by

JavaScript Array entries() Method method returns a new Array Iterator object with key/value pairs. This method does not change the original array.


JavaScript Array entries()

A simple example code creates an Array Iterator, and then iterates over the key/value pairs:

<!DOCTYPE html>
    let words = ["Apple", "Ball", "Cat", "Dog"];

    const w = words.entries();

    for (let x of w) {



JavaScript Array entries

More examples

const array1 = ['a', 'b', 'c'];

const iterator1 = array1.entries();

console.log(; //[0, "a"]

console.log(;// [1, "b"]

Iterating with index and element

const a = ["a", "b", "c"];

for (const [index, element] of a.entries()) {
  console.log(index, element);

Using a for…of loop

const array = ["a", "b", "c"];
const arrayEntries = array.entries();

for (const element of arrayEntries) {

Do comment if you have any doubts or suggestions on this JS Array method tutorial.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *