Here's the brief example of how map works with JS (Java Script) by MDN.
The
Code Ex:
//Example Array
var array1 = [1, 7, 9, 16];
// pass a function to map
const map1 = array1.map(x => x * 2);
console.log(map1);
// expected output: Array [2, 14, 18, 32]
The
map()
method creates a new array with the results of calling a provided function on every element in the calling array.Code Ex:
//Example Array
var array1 = [1, 7, 9, 16];
// pass a function to map
const map1 = array1.map(x => x * 2);
console.log(map1);
// expected output: Array [2, 14, 18, 32]
var new_array = arr.map(function callback(currentValue[, index[, array]]) { // Return element for new_array }[, thisArg])
Have your Code And Test it from here some trusted resources
https://jsbin.com &&
No comments:
Post a Comment