DEV Community

Discussion on: 7 Tricks I Use To Rewrite JavaScript Code From My Early Days

Collapse
 
momander profile image
Martin Omander

About "for...of": I find myself using it often with async/await. Foreach() does not work well with asynchronous code. I think this was the author's point.
For more background see this: stackoverflow.com/questions/375766...

Collapse
 
lexlohr profile image
Alex Lohr

It depends. If you want to wait on a list of promises returned by an array of functions, better use await Promise.all(fns.map(fn => fn()), as it will allow you to run them parallel.