Mapping an array

The map method produces a new array by applying the given function to each element of an existing array.

Consider the following program which applies the result of a function to each element in an array using a for loop, and a more concise way to apply the function with map.

You can use an inline arrow function with map to quickly transform an array of values.

Was this page helpful?