The keys() method returns an Array Iterator with the keys of an array.
The keys() method returns an Array Iterator with the keys of an array.
array.keys()
No parameters.
An Array Iterator object
Create an Array Iterator object, with keys for each item in the array:
var myArray = ["XML", "Json", "Database", "Mango"]; var x = myArray.keys(); console.log( x.next().value);//from w ww. j a va 2s .c om console.log( x.next().value); console.log( x.next().value); console.log( x.next().value); //Array keys() method returns a new Array Iterator that //contains the keys for each index in the array: const breakfast = ['XMLs', 'Screens', 'Keyboards']; const kBreakfast = breakfast.keys(); console.log(kBreakfast.next().value); // 0 console.log(kBreakfast.next().value); // 1 console.log(kBreakfast.next().value); // 2