Array.prototype.keysadvancedconst arr = ['a', 'b']
[...arr.keys()] // β [0, 1] (indices only)
[...arr.entries()] // β [[0,'a'],[1,'b']] (index+value pairs)Use keys() for indices only; use entries() when you need both the index and the value.
keys() gives you just the indices, while entries() gives you [index, value] pairs. When you only need the indices to look up values manually, keys() is the right choice.
Challenge: Implement indexMap(arr) that returns an object mapping each numeric index to its corresponding array value.
indexMap(['a', 'b', 'c']) // β { 0: 'a', 1: 'b', 2: 'c' }
indexMap([]) // β {}