Created
January 25, 2019 22:24
-
-
Save hamg26/3c8b8357368834183d9b59e35c841d9c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********* | |
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