I know that the map()
method passes each element of the array on which it is invoked to the function you specify and returns an array containing the values returned by your function. For example:
[1,2,3].map(function(x){return x+1});
or
[1,2,3].map(x => x+1)
gives [ 2, 3, 4 ]
.
However, have a look at the following code segment
['A', 'B', 'C'].map(function(current, index, array)) { balabala }
This kind of segment can be found for example at to-title-case.
I wonder what do current
, index
, array
represent respectively. Before then I think that any function in map()
should have only one parameter.