Created
October 1, 2021 01:29
-
-
Save jerlyrosa/29538a5cf2c2a00ff63b7114806ab17b to your computer and use it in GitHub Desktop.
Ejemplos de closures
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
// CLOSURE | |
const anotherFunction = () =>{ | |
var count = 0; | |
const countFuction =(value)=>{ | |
return count += value; | |
} | |
return countFuction; | |
} | |
let test = anotherFunction(); | |
test(1); | |
test(1); | |
test(1); | |
let zz = 1 | |
//Recoradando el habito lexico. | |
const buildCount= (value) =>{ | |
var count = value; | |
const countFuction =(value)=>{; | |
return console.log(count++) | |
} | |
return countFuction; | |
} | |
let test2 = buildCount(1); | |
test2(); | |
test2(); | |
let test3 = buildCount(5); | |
test3(); | |
test3(); | |
const fruits = () => { | |
console.log(fruit2) | |
if (true) { | |
var fruit1 = 'apple'; | |
const fruit2 = 'banana'; | |
let fruit3 = 'kiwi'; | |
} | |
} | |
console.log(3**2) | |
fruits() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment