map()
The map()
method is a higher-order function that creates a new array by applying a callback function to each element of an existing array.
Example
map()
iterates over each element innumbers
.The callback function (
number * 2
) doubles each value.The result is stored in
doubledNumbers
, without modifying the original array.
Last updated