The JavaScript Map method is a method that maps an object of key-value pairs with a function. This is done by iterating over the object’s keys and invoking the function with the corresponding values in order.
var arr = [1,2,3,4,5,6,7,8,9,10];
var newArr = arr.map(function(item, index, array) {
return item * 2;
});
console.log(newArr); // [ 2,4,6,8,10,12,14,16,18,20 ]
Leave a Reply