Last active
August 29, 2015 14:17
-
-
Save cgrinaldi/c87971ea3411d8c3f89b to your computer and use it in GitHub Desktop.
A simple example of hoisting with function expressions
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
sayHello(); // will error out (see below for reason) | |
var sayHello = function() { | |
console.log('Hello, world!'); | |
}; |
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
var sayHello; // currently undefined | |
sayHello(); // undefined is not a function | |
sayHello = function() { // only here is the variable assigned | |
console.log('Hello, world!'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment