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
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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.