Home >>JavaScript Array Reference >JavaScript Array entries() Method

JavaScript Array entries() Method

JavaScript Array entries() Method

The array entries() method is an inbuilt method in JavaScript which is used to return an Iterator object that contains key and value pairs for each index of an array.

Syntax:
array.entries();

Browser Support

Method Chrome Edge Firefox Safari Opera
array.entries(); 38.0 12.0 28.0 8 25.0
Here is an example of JavaScript array entries() Method:
<html>
<body>
<p id="entries"></p>
<script>
var e = ["red", "green", "Blue", "white"];
var f = e.entries();
for (x of f) 
{
  document.getElementById("entries").innerHTML += x + "<br>";
}
</script>
</body>
</html>
Output:

Example 2:
<html>
<body>
   <button onclick="displayent()">Result</button>
   <p id="entries"></p>
   <script>
      var pointsArr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1000];
      var res = pointsArr.entries();
      for (val of res) {
         document.getElementById("entries").innerHTML += val + "<br>";
      }
      function pointsFunc(points) {
         return points == 550;
      }
      function displayent() {
         document.getElementById("entries").innerHTML = pointsArr.some(pointsFunc);
      }
   </script>
</body>
</html>
Output:


No Sidebar ads