DEV Community

Discussion on: Useful JS functions you aren't using: Array.map

Collapse
 
tiffany profile image
tiff

Just so I'm clear as a junior: map() does not mutate an array just makes a new one?

Collapse
 
aeiche profile image
Aaron Eiche

Correct, array.map returns a new array that will not mutate your old one.

You could conceivably alter your original array while in the function executing on a key, but then you're out of the realm of using


 anyway.
Enter fullscreen mode Exit fullscreen mode
Collapse
 
tiffany profile image
tiff

I was about to ask if you meant a key as in an index in the array. I forgot that Arrays are objects in JavaScript, as pretty much everything else. But still, I am not sure what you mean by the function executing on a key.