How to loop an array with `for...of`?
const words = ['Hallo Welt', 'Nani?', '42']
// for-of loop
// output: Hallo Welt 0, Nani? 1, 42 2
for(const [index, word] of words.entries()) {
console.log(word, index)
}
September 2nd, 2019
for...of
will execute statements on each value. Can be used for so-called iterable objects.