Created
June 30, 2018 03:39
-
-
Save samzhao/8834c9f8f7350a68ba21c6daf3dc93c7 to your computer and use it in GitHub Desktop.
Bad example of using async/await for delaying calls in a loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const delay = time => | |
new Promise(resolve => setTimeout(resolve, time)); | |
const list = new Array(10).fill(); | |
list.forEach(async (_, index) => { | |
await delay(1000); | |
console.log(index); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment