DEV Community

Discussion on: Stop abusing .map()!

Collapse
 
brianmcbride profile image
Brian McBride

I guess incorrect use of Map is really only an issue if it is harming the app performance. Someone dealing with huge datasets will see that. Otherwise the returned array is going to be garbage collected after the containing function exits.

Still, better to use the right tools. And you know, there is a lot of docs for that!
developer.mozilla.org/en-US/docs/W...

It is good to know many of these. I mean, who uses copyWithin()? I mean, handy, but I haven't needed that edge case myself. includes() and some() are ones I don't see used often, but are handy (some is sort of like findIndex but returns boolean).

Collapse
 
davidmaxwaterman profile image
Max Waterman

I guess incorrect use of Map is really only an issue if it is harming the app performance.

I think it's more of an issue on developer performance - ie the word 'map' has a meaning that the developer understands, and if they read 'map', the notice that the results of the map are thrown away, it leads to a brain fart (aka 'wtf?'). forEach has no such smell.