Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save hubertcross/481dcda7e563ad2fa3e26eacef9cd5c4 to your computer and use it in GitHub Desktop.

Select an option

Save hubertcross/481dcda7e563ad2fa3e26eacef9cd5c4 to your computer and use it in GitHub Desktop.
How to do async for each loop!!
async function asyncForEach(array, callback) {
const results = [];
for (let index = 0; index < array.length; index +=
results.push(callback(array[index], index, array)
}
await Promise.all(results);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment