Created
June 12, 2020 00:04
-
-
Save agustinpfs/cc541192f866c63703ce29874ac165a5 to your computer and use it in GitHub Desktop.
Javascript básico. Ejemplos funciones.
This file contains 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
// function myFuncion() { | |
// return 3 + 4; | |
// } | |
// console.log(myFuncion()); // 7 | |
// function myFuncion(a, b) { | |
// return a + b; | |
// } | |
// //invocación: | |
// console.log(myFuncion(3, 4)); // 7 | |
function myFuncion() { | |
alert("Hola Mundo"); | |
} | |
console.log(myFuncion()); | |
// arrow functions | |
// sintaxis | |
let mifuncion = () => { | |
//código de la función | |
} | |
// parámetros | |
let nombreFuncion = (importe) => { | |
console.log("total", importe) | |
} | |
nombreFuncion(300) //total 300 | |
// or (unicamente si es un solo parámetro) | |
let nombreFuncion = importe => { | |
console.log("total", importe) | |
} | |
nombreFuncion(300) //total 300 | |
// sin llaves (unicamente si es una sola linea de código) | |
let nombreFuncion = importe => console.log("total", importe) | |
nombreFuncion(300) //total 300 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment