DEV Community

Discussion on: Stop using Array.map() everywhere πŸ₯΅

Collapse
 
jakecarpenter profile image
Jake Carpenter

Getting a new array is very much the point. We do this to avoid side effects that are difficult to track. It’s the same reason functions should return a value, not modify a reference.

Immutability by default is a solid strategy that helps avoid countless bugs. Only modify the original array when you have proven map to be a performance bottleneck - and it’s rare.

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