Last active
September 1, 2017 12:52
-
-
Save MedinaGitHub/cbec75f3137ebab7160199bdacc2086e to your computer and use it in GitHub Desktop.
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
//Funcion normal | |
var suma1 = function (valor) { | |
return valor + valor; | |
} | |
console.log(suma1(1));//Resultado = 2 | |
//Funcion EC6 | |
let suma2 = valor => valor + valor; | |
console.log(suma2(1));//Resultado = 2 | |
//Sumando el parametro con variable interna (al declarar una variable hay que agregar corchetes) | |
let suma2 = valor =>{ var x = 1 ; return valor + x}; | |
console.log(suma2(1));//Resultado = 2 | |
//Dos parametros | |
let sumar = (num1, num2) => num1 + num2; | |
console.log(sumar(1, 2)) //Resultado = 3 | |
//Funcion sin parametros | |
let saludar = () => "hola mundo"; | |
console.log(saludar);//Resultado Hola Mundo | |
//funcion anonima | |
var saludo3 = (nombre => `hola anonimo ${nombre}`)("imprime seba"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment