Skip to content

Instantly share code, notes, and snippets.

@arunrreddy
Created June 9, 2020 06:43
Show Gist options
  • Select an option

  • Save arunrreddy/86d4020833059ddf07acb74022c64df6 to your computer and use it in GitHub Desktop.

Select an option

Save arunrreddy/86d4020833059ddf07acb74022c64df6 to your computer and use it in GitHub Desktop.
BJS Intro - Scoping in JS
function myFunction() {
var a = 10;
if (a === 10) {
var a = 30;
let b = 20;
} else {
let c = 30;
}
console.log(a);
console.log(b);
console.log(c);
}
myFunction();
// 30
// Uncaught ReferenceError: b is not defined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment