Page 124 - JavaScript
P. 124

The entries() method returns a new Array Iterator object that contains the key/value pairs for each
        index in the array.


        6


         var letters = ['a','b','c'];

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


        result


         0 "a"
         1 "b"
         2 "c"


        Note: This method is not supported in Internet Explorer.


        Portions of this content from Array.prototype.entries by Mozilla Contributors licensed under CC-
        by-SA 2.5


        Read Arrays online: https://riptutorial.com/javascript/topic/187/arrays






















































        https://riptutorial.com/                                                                               81
   119   120   121   122   123   124   125   126   127   128   129