Created
July 7, 2020 17:58
-
-
Save agustinpfs/ab6cccba055879d7281fdfb5b46c433a to your computer and use it in GitHub Desktop.
Javascript básico. Arrow functions (funciones flecha).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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