Last active
February 25, 2020 19:40
-
-
Save munkacsitomi/c84db5038a0181b85db5af1f77664f4b to your computer and use it in GitHub Desktop.
Closures
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
const outerValue = 'samurai'; | |
let later; | |
function outerFunction() { | |
const innerValue = 'ninja'; | |
function innerFunction() { | |
console.log(outerValue === 'samurai', 'I can see the samurai.'); | |
console.log(innerValue === 'ninja', 'I can see the ninja.'); | |
} | |
later = innerFunction; | |
} | |
outerFunction(); | |
later(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment