Knowledgize

.keys()

Returns a new Array Iterator object that contains the keys for each index in the array.

Examples:

let fruits = ['apple', 'banana', 'mango']; let keys = fruits.keys(); for (let key of keys) { console.log(key); } // 0 // 1 // 2
let items = ['item1', 'item2', 'item3']; let itemKeys = items.keys(); console.log(Array.from(itemKeys)); // [0, 1, 2]