DEV Community

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

Collapse
 
drarig29 profile image
Corentin Girard

You missed the point of the article I think. The whole point of the article is to say that semantically, a map() should be stored in a variable because it creates a new array. And that if you don't care about the result and just want to do side-effects in a "functional" way (here, I use the word "functional" as opposited to with an actual for-loop statement), just use forEach() instead.

Yes, sometimes reduce() will be better and you should refactor to use it, but that's not the point here.

And yes, the argument of memory consumption was a bad way to try giving a reason not to not store the result of a map().

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