for-await

for await of VS Promise.all

一笑奈何 提交于 2020-06-06 07:52:12
问题 Is there any difference between this: const promises = await Promise.all(items.map(e => somethingAsync(e))); for (const res of promises) { // do some calculations } And this ? for await (const res of items.map(e => somethingAsync(e))) { // do some calculations } I know that in the first snippet, all the promises are fired at the same time but I'm not sure about the second. Does the for loop wait for the first iteration to be done to call the next promise ? Or are all the promises fired at the