Answers for "javascript map over new array"

23

array map javascript

const array1 = [1, 4, 9, 16];

// pass a function to map
const map1 = array1.map(x => x * 2);

console.log(map1);
// expected output: Array [2, 8, 18, 32]
Posted by: Guest on November-25-2019
0

javascript map over new array

// With ES6, you can do this:

[...Array(10)].map((a, b) => a)
Posted by: Guest on January-06-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language