- Array.map() function iterate through every element in array only once.
- It do not alter original array but return new array when called.
For example.
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)
Top comments (0)