map()
method
ES5
Creates a new array populated with the results of calling a function on every element.
Syntax
array.map(callback(element, index, array))
Example
javascript
const numbers = [1, 2, 3, 4, 5];
const doubled = numbers.map(n => n * 2);
console.log(doubled); // [2, 4, 6, 8, 10]
const users = [{name: 'Alice', age: 28}, {name: 'Bob', age: 34}];
const names = users.map(user => user.name);
console.log(names); // ['Alice', 'Bob']