Created
July 21, 2012 01:47
-
-
Save STRML/3154212 to your computer and use it in GitHub Desktop.
Variable declaration hoisting
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(){bar = 10; var bar = 20;}()); | |
alert(bar) // ReferenceError: bar is not defined | |
(function foo(){bar = 10;}()); | |
alert(bar) // 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment