Last active
June 7, 2023 05:39
-
-
Save decentraliser/6839761213ae9be7b4fb5025892d9108 to your computer and use it in GitHub Desktop.
Promises iteration with for of
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 promise = (number) => new Promise(resolve => { | |
setTimeout(() => resolve(number), Math.random() * Math.floor(1000)) | |
}) | |
const sequentialIteration = async () => { | |
for (const number of Array(10).keys()) console.log(await promise(number)) | |
} | |
sequentialIteration() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment