Skip to content

Instantly share code, notes, and snippets.

@hamg26
Created January 25, 2019 22:24
Show Gist options
  • Save hamg26/3c8b8357368834183d9b59e35c841d9c to your computer and use it in GitHub Desktop.
Save hamg26/3c8b8357368834183d9b59e35c841d9c to your computer and use it in GitHub Desktop.
/*********
1
*********/
var a = 12;
var superFunction = function () {
console.log(a);
var a = 80;
};
superFunction ();
// should log `undefined`, when the `console.log` is reached `a` is not defined yet
/*********
2
*********/
( function () {
try {
throw new Error();
}
catch (a) {
var a = 1, b = 2;
console.log(a);
}
console.log(a);
console.log(b);
} )();
// Should log `1`, `undefined` and then `2`
// `a` gets undefined outside the catch scope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment