Skip to content

Instantly share code, notes, and snippets.

@decentraliser
Last active June 7, 2023 05:39
Show Gist options
  • Save decentraliser/6839761213ae9be7b4fb5025892d9108 to your computer and use it in GitHub Desktop.
Save decentraliser/6839761213ae9be7b4fb5025892d9108 to your computer and use it in GitHub Desktop.
Promises iteration with for of
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