๐บ๏ธArray.map()
Array.map()
Array.map()
.map
no mutation
.map
no mutation
Description
The map() method creates a new array with the results of calling a provided function on every element in this array.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
Example
Description
The map() method creates a new array with the results of calling a provided function on every element in this array.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
Example
Calls a function on each array element and returns the result as new array. Or feeds all hungry monkeys.
_Documentation on _MDN
map()
map
method will create a new array of elements where each element is a value returned from the function provided. The example above shows the function provided doubling each element. Hence, mapArray
is [2, 4, 6, 8]
.
Note
: just like filter method, map will not mutate the original array because it will create a new array.
Last updated