Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

JavaScript Array entries() Method

  • Difficulty Level : Basic
  • Last Updated : 23 Jun, 2020

Below is the example of the Array entries() method.

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

  • Example:

    <!DOCTYPE html>
        <body style="text-align: center;">
            <h1 style="color: green;">
              JavaScript | Array entries() Method
            <p id="geeks"></p>
                var lnaguages = ["HTML", "CSS", 
                                 "JavaScript", "ReactJS"];
                var g = lnaguages.entries();
                for (x of g) {
                      .innerHTML += x + "<br>";
  • Output:

The arr.entries() method is used to get a new Array that contains the key and value pairs for each index of an array.



Parameters: This method does not accept any parameter.

Return value: It returns an array of indexes and values of the given array on which arr.entries() method is going to work.

More example codes for the above method are as follows:

Program 1:

    var arr = ["HTML", "CSS", "JS"
               "Bootstrap", "PHP"];
    var seqn = arr.entries();
    document.write("Applying the Array entries method:"
                   + "<br>");
    for (var x of seqn) {
        document.write(x + "</br>");


Applying the Array entries method:

Program 2:

    const x = ["Geeks", "for", "Geeks"];
    for (const [index, element] of x.entries()) 
      document.write(index, element);



Supported Browsers: The browsers supported by JavaScript Array entries() method are listed below:

  • Google Chrome 38.0
  • Microsoft Edge 12.0
  • Mozilla Firefox 28.0
  • Safari 8.0
  • Opera 25.0

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!