The following is a description of the map function:
arr.map(callback[, thisArg])
callback
A function that creates an element of a new array using three arguments:
currentValue
The current item is processed in an array.
index
The index of the current item is processed in the array.
array
An array map has been called up.
The map function takes a callback function as an argument (and not as an index as an argument, as originally stated in the question before editing it). The callback function has an index as a parameter - the callback is called automatically, so you do not provide the index yourself. If you only need the current value, you can omit other parameters.
Kapep Oct. 14 '14 at 10:01 2014-10-14 22:01
source share