JavaScript Array map()
JavaScript Array map()
The map() method is to create a new array by calling a function for every array element. It calls a function once for each element in an array. It does not execute the function for empty elements and does not change the original array.
Syntax:-
Its syntax is:- array.map(function(currentValue, index, arr), thisValue)
Return:-
Its return is:- the new resulted array
Further Explanation:-
Parameter | Description |
function() | Required. A function to be run for each array element. |
currentValue | Required. The value of the current element. |
index | Optional. The index of the current element. |
arr | Optional. The array of the current element. |
thisValue | Optional. A value is passed to the function to be used as this value. Default value is undefined. |