Last active
April 15, 2016 17:55
-
-
Save alexweber/a62eeaceb86029f0b7abf91884e70671 to your computer and use it in GitHub Desktop.
Hoisting examples
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
// Example 1 | |
var foo = 1; | |
function bar() { | |
if (!foo) { | |
var foo = 10; | |
} | |
alert(foo); | |
} | |
bar(); | |
// Example 2 | |
var a = 1; | |
function b() { | |
a = 10; | |
return; | |
function a() {} | |
} | |
b(); | |
alert(a); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works too