loading
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
async function asyncForEach(array, callback) {
  for (let index = 0; index < array.length; index++) {
    await callback(array[index], index, array);
  }
}

const waitFor = (ms) => new Promise(r => setTimeout(r, ms));
async function main() {
  asyncForEach([1, 2, 3], async n => {
    await waitFor(1000);
    console.log(`main 'asyncForEach' num=${n}`)
  })
}

main();