Skip to content

Instantly share code, notes, and snippets.

@alvaro-prieto
Created September 21, 2017 09:21
Show Gist options
  • Save alvaro-prieto/081cb49f2c29d7e04cfe79dac1ff610e to your computer and use it in GitHub Desktop.
Save alvaro-prieto/081cb49f2c29d7e04cfe79dac1ff610e to your computer and use it in GitHub Desktop.
Ejecutar una funcion sobre cada elemento de un array y retornar un nuevo array
let numbers = [1, 5, 10, 15];
let doubles = numbers.map( x => x * 2);
//el original no se altera
//tambien se le puede pasar una funcion por parametro como referencia, obviamente
let raices= numbers.map(Math.sqrt);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment