DEV Community


Posted on

The JS map() method

The map() method in JavaScript returns to you a new array by calling a function for every element it does not mutate. The original array just creates a copy this is used a lot in React so is something good to know along with other JS methods.

const numbersList = [1, 2, 4, 5];

// example
const mapArr = => n + 1);

// Output [2, 3, 5, 6];
// I will also console the original array to see no changes made

Top comments (0)