ES6 - Array.entries



This function returns a new Array Iterator object that contains the key/value pairs for each index in the array.

Syntax

The syntax given below is for the array method entries().

array.entries()

Example

<script>
   //enties
   let cgpa_list = [7.5,8.5,6.5,9.5]
   let iter = cgpa_list.entries()
   for(let cgpa of iter){
      console.log(cgpa[1])
   }
</script>

The output of the above code will be as shown below −

7.5
8.5
6.5
9.5
Advertisements