What is the ES6 equivalent of Python 'enumerate' for a sequence? What is the ES6 equivalent of Python 'enumerate' for a sequence? javascript javascript

What is the ES6 equivalent of Python 'enumerate' for a sequence?


Yes there is, check out Array.prototype.entries().

const foobar = ['A', 'B', 'C'];for (const [index, element] of foobar.entries()) {  console.log(index, element);}