ES5 Array.map() function for #React Quick Notes

  1. Array.map() function iterate through every element in array only once.
  2. It do not alter original array but return new array when called.
let myArray = [1,2,3];

var newArrayMultipleOfOldArray = myArray.map(x=>x*2);
console.log(newArrayMultipleOfOldArray );

//Below reference is from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map

// Arrow function
map((element) => { /* … */ })
map((element, index) => { /* … */ })
map((element, index, array) => { /* … */ })

// Callback function
map(callbackFn)
map(callbackFn, thisArg)

// Inline callback function
map(function(element) { /* … */ })
map(function(element, index) { /* … */ })
map(function(element, index, array){ /* … */ })
map(function(element, index, array) { /* … */ }, thisArg)