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

1 min read
- Array.map() function iterate through every element in array only once.
- 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)
0
Subscribe to my newsletter
Read articles from Ajay Baraiya directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
