Loop (for each) over an array in JavaScript
TL;DR Your best bets are usually a for-of loop (ES2015+ only; spec | MDN) – simple and async-friendly for (const element of theArray) { // …use `element`… } forEach (ES5+ only; spec | MDN) (or its relatives some and such) – not async-friendly (but see details) theArray.forEach(element => { // …use `element`… }); a simple … Read more