Last active
December 17, 2015 06:19
-
-
Save vadimii/5564861 to your computer and use it in GitHub Desktop.
JavaScript variable declaration test
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
window.test = 'global test'; | |
(function () { | |
console.log(typeof test); // "undefined" | |
var test = 'context test'; | |
console.log(test); // "context test" | |
})(); | |
console.log(test); // "global test" |
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
window.test = 'global test'; | |
(function () { | |
var test; // moved by interpreter | |
console.log(typeof test); // "undefined" | |
test = 'context test'; | |
console.log(test); // "context test" | |
})(); | |
console.log(test); // "global test" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment