3 ms·
Your example is equal to await getThingAtIndex(1) await getThingAtIndex(2) await getThingAtIndex(3) whereas the async for loop is equivalent to await
by spiralx 9y ago
Your example is equal to
await getThingAtIndex(1)
await getThingAtIndex(2)
await getThingAtIndex(3)
whereas the async for loop is equivalent to
await Promise.all([
getThingAtIndex(1),
getThingAtIndex(2),
getThingAtIndex(3)
])
Your example is valid syntax, but it executes each call synchronously.
- xeromal 9y agoThe article says `This feature adds a new “for-await-of” loop that allows us to call async functions that return promises (or Arrays with a bunch of promises) in a loop. The cool thing is that the loop waits for each Promise to resolve before doing to the next loop.`. which seems to be in contention with what you say.