Skip to content

Instantly share code, notes, and snippets.

@pszponder
Created June 20, 2021 03:31
Show Gist options
  • Save pszponder/585f7f2b3000e51ffe2508b2436a2093 to your computer and use it in GitHub Desktop.
Save pszponder/585f7f2b3000e51ffe2508b2436a2093 to your computer and use it in GitHub Desktop.
// Var does not follow block scoping
{
var a = 1;
console.log(a); // 1
}
console.log(a); // 1
{
{
var b = 2;
console.log(b); // 2
}
// 2 (if b was declared using let or const, you would get a ReferenceError)
console.log(b);
}
console.log(b); // 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment