Answers for "what does map function do javascript"

4

how the map function works javascript

const array = [2, 5, 9];
let squares = array.map((num) => num * num);

console.log(array); // [2, 5, 9]
console.log(squares); // [4, 25, 81]
Posted by: Guest on April-07-2020
1

javascript map

// make new array from edited items of another array
var newArray = unchangedArray.map(function(item, index){
  return item;	// do something to returned item
});

// same in ES6 style (IE not supported)
var newArray = unchangedArray.map((item, index) => item);
Posted by: Guest on February-18-2021
4

javascript map

The map() method creates a new array with the results of calling a provided function on every element in the calling array.
Posted by: Guest on December-22-2019

Code answers related to "what does map function do javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language