Map method in javaScript

 

Map() method:-

  • Creates a new array for calling function for all array element
  • Calls a function once for every element
  • Does not execute the function for empty element
  • Does not change the original array

Syntax:-

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

function()           :-    a function to be run for all element
currentValue    :-    value of current element
index                      :-     index of current 
arr                           :-    holds the array
thisValue              :-    default value passed to the function to be used as its this value.

Post a Comment

2 Comments