Skip to content

Instantly share code, notes, and snippets.

@moisescastillo
Last active July 11, 2020 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moisescastillo/457ef0ec25b3e7bbd97e53bd7cee75da to your computer and use it in GitHub Desktop.
Save moisescastillo/457ef0ec25b3e7bbd97e53bd7cee75da to your computer and use it in GitHub Desktop.
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