Vanilla Pills


Array.prototype.map()

The map() method creates a new array populated with the results of calling a provided function on every element in the calling array.

1const numbers = [1, 2, 3, 4, 5];
2const doubled = numbers.map((number) => number * 2);
3console.log(doubled); // [2, 4, 6, 8, 10]