Skip to content

Instantly share code, notes, and snippets.

@helabenkhalfallah
Last active May 15, 2021 20:24
Show Gist options
  • Save helabenkhalfallah/9cd5b397dde86635ec4652cbb8b87b34 to your computer and use it in GitHub Desktop.
Save helabenkhalfallah/9cd5b397dde86635ec4652cbb8b87b34 to your computer and use it in GitHub Desktop.
JS nested scopes
const globalVar = 'global';
const outerFunc = () => {
const outerVar = 'outer';
const innerFunc = () => {
const innerVar = 'inner'
console.log(innerVar, outerVar, globalVar); // "inner", "outer", "global"
}
console.log(outerVar, globalVar); // "outer", "global"
innerFunc();
}
outerFunc();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment