Skip to content

Instantly share code, notes, and snippets.

@moisescastillo

moisescastillo/JS_map.js

Last active Jul 11, 2020
Embed
What would you like to do?
JavaScript map method
// JS: map() method
let clientes = [
{nombre: "Luis", edad: 22},
{nombre: "Alberto", edad: 31},
{nombre: "Eduardo", edad: 19}
];
let foo = clientes.map(function(cliente) {
return cliente.nombre;
});
let bar = clientes.map((cliente) => cliente.nombre);
console.log(foo);
// ["Luis","Alberto","Eduardo"]
console.log(bar);
// ["Luis","Alberto","Eduardo"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment