Javascript array map() is an inbuilt function that creates the new array with the results of a provided function on every item in the calling array. The map() function calls the provided callback function once for each element in the array and in order and constructs the new array from the results.

The Javascript array map() function is a  pure function, and it does not modify the existing array instead it will return a new array.

Javascript array map example

The map() method calls the provided function once for each element in an  array, in order.

The  callback function is invoked with the following three arguments: the value of the element, the index of the element, and the Array object that is being traversed. The syntax is the following.

array.map(function(currentValue, index, arr), thisValue)

The currentValue is a required parameter, and it is the current value of the element.

The index is an optional parameter, and it is the index of the current element.

#javascript #array.prototype.map #currentvalue

Javascript Array Map Example | Array.prototype.map()
2.25 GEEK