DEV Community

Discussion on: Using await in loop cause performance issues

Collapse
 
urielsouza29 profile image
Uriel dos Santos Souza

for await...of ?

Collapse
 
chandelieraxel profile image
Chandelier Axel

Is doing the job performance wise, but has no practical uses for this specific use case. We would have to loop once to build the array of Promises, then loop another time within the for await...of in order to get the datas.

Another downside is that you can't (I think ?) handle the Promises rejection nicely within a for await...of. If one of them reject, you'll have a runtime errors, where Promise.all() has a fail fast built-in, and will reject if any of the Promise reject