Skip to content

Instantly share code, notes, and snippets.

@camilomontoyau
Created October 21, 2020 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camilomontoyau/acee99a580ed5ba97b2d98da4c4926b3 to your computer and use it in GitHub Desktop.
Save camilomontoyau/acee99a580ed5ba97b2d98da4c4926b3 to your computer and use it in GitHub Desktop.
javascript scope
const a = 1;
const b = 2;
const c = 3;
(function firstFunction() {
const b = 5;
const c = 6;
(function secondFunction() {
const b = 8;
(function thirdFunction() {
const a = 7;
const c = 9;
(function fourthFunction() {
const a = 1;
const c = 8;
})();
})();
})();
})();
console.log(`a: ${a}, b: ${b}, c: ${c}`);
// wanted output a: 1, b: 8, c: 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment