Skip to content

Instantly share code, notes, and snippets.

@KinoAR
Created July 13, 2017 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KinoAR/f26b5e98b90bb567be807b8b243d534f to your computer and use it in GitHub Desktop.
Save KinoAR/f26b5e98b90bb567be807b8b243d534f to your computer and use it in GitHub Desktop.
Example of function and variable hoisting.
/* 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