map()
ES5+Creates a new array with the results of calling a provided function on every element in the calling array.
Syntax
array.map(callback(element, index, array), thisArg)Parameters
callback Function Function that produces an element of the new Array
thisArg any optionalValue to use as this when executing callback
Return Value
Array
A new array with each element being the result of the callback function
Examples
JavaScript
const numbers = [1, 2, 3, 4];
const doubled = numbers.map(x => x * 2);
console.log(doubled); Output:
// [2, 4, 6, 8]