DEV Community

Discussion on: Stop using Array.map() everywhere 🥵

Collapse
 
hellnar profile image
Stas Klymenko

map - if you expect an array as a result.
reduce - if you expect one value as a result.
forEach - if you don't need to return a result. Better for sync code.
for of - if you don't need to return a result and you might break the loop. Better for async code.

Collapse
 
drarig29 profile image
Corentin Girard

Note that you can use functions like Promise.all() with map() too.

Some comments have been hidden by the post's author - find out more