Created
July 13, 2017 18:00
-
-
Save KinoAR/f26b5e98b90bb567be807b8b243d534f to your computer and use it in GitHub Desktop.
Example of function and variable 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 Hoisting Example */ | |
//This will run despite being declared below | |
console.log(myFuction()); | |
//This also applies to variables although x = undefined here | |
console.log("x value:", x); | |
function myFuction() { | |
console.log("I was called"); | |
} | |
console.log("I was created"); | |
//Will assign x properly here | |
var x = 5; | |
console.log("x value:", x); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment