Skip to content

Instantly share code, notes, and snippets.

@STRML
Created Jul 21, 2012
Embed
What would you like to do?
Variable declaration hoisting
(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