Created
February 26, 2015 22:54
-
-
Save sym3tri/3bddc8c3719fd484536a to your computer and use it in GitHub Desktop.
example of how javascript hoisting works
This file contains 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
function foo() { | |
var myvar = 'my value'; | |
(function() { | |
alert(myvar); // undefined | |
var myvar = 'local value'; | |
})(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment