JavaScript Enumerate com índice

const iterable = [...];
for (const [index, elem] in iterable.entries()) {
  f(index, elem);
}

// or
iterable.forEach((elem, index) => {
  f(index, elem);
});
Angry Alpaca