Array.prototype.map()
Create a new Array[], by calling a function on each element in a different Array[]
const users = [
{ name: 'Alex' },
{ name: 'Bob' },
{ name: 'Carl'}
];
// Imperative Programming using For Loops
const usernames = [];
for (const user of users){
usernames.push(user.name);
}
// Declarative Programming using Array Map
const usernames = users.map(user => user.name);
// Another usecase where we use each item on a function
const requests = users.map(user => fetch(user.name) )
await Promise.all(requests)