Skip to content

Instantly share code, notes, and snippets.

@agustinpfs
Created July 7, 2020 17:58
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 agustinpfs/ab6cccba055879d7281fdfb5b46c433a to your computer and use it in GitHub Desktop.
Save agustinpfs/ab6cccba055879d7281fdfb5b46c433a to your computer and use it in GitHub Desktop.
Javascript básico. Arrow functions (funciones flecha).
let nombreFuncion = () => {
//código
}
// Los parámetros siguen estando entre paréntesis, esta vez antes de la flecha (function).
let nombreFuncion = (importe) => {
console.log("total", importe)
}
nombreFuncion(300) //total 300
// Si sólo tiene un parámetro los paréntesis no son obligatorios:
let nombreFuncion = importe => {
console.log("total", importe)
}
nombreFuncion(300) //total 300
// Y si solo temenos una línea de código podemos obviar las llaves:
let nombreFuncion = importe => console.log("total", importe)
// También podemos obviar la palabra clave “return”:
let myFuncion = () => 3 + 4;
myFuncion(); // 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment