Skip to content

Instantly share code, notes, and snippets.

@agustinpfs
Created June 12, 2020 00:04
Show Gist options
  • Save agustinpfs/cc541192f866c63703ce29874ac165a5 to your computer and use it in GitHub Desktop.
Save agustinpfs/cc541192f866c63703ce29874ac165a5 to your computer and use it in GitHub Desktop.
Javascript básico. Ejemplos funciones.
// 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