Skip to content

Instantly share code, notes, and snippets.

@Atinux
Created October 3, 2017 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Atinux/f0060a1abec444e11a992d6ccc8b3847 to your computer and use it in GitHub Desktop.
Save Atinux/f0060a1abec444e11a992d6ccc8b3847 to your computer and use it in GitHub Desktop.
forEach example with async/await (fail)
const waitFor = (ms) => new Promise((resolve) => setTimeout(resolve, (ms || 0)))
[1, 2, 3].forEach(async (num) => {
await waitFor(50)
console.log(num)
})
console.log('Done')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment