Skip to content

Instantly share code, notes, and snippets.

@yatki
Created March 22, 2019 14:09
Show Gist options
  • Select an option

  • Save yatki/fe561fd8f88ef63334d6f9838e9c12fa to your computer and use it in GitHub Desktop.

Select an option

Save yatki/fe561fd8f88ef63334d6f9838e9c12fa to your computer and use it in GitHub Desktop.
for await of example
const x = [
new Promise(resolve => setTimeout(() => resolve('500'), 500)),
new Promise(resolve => setTimeout(() => resolve('600'), 600)),
new Promise(resolve => setTimeout(() => resolve('100'), 100)),
]
for await (let o of x) {
console.log(o);
}
/**
* Output:
500
600
100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment