Skip to content

Instantly share code, notes, and snippets.

@reime005
Created June 16, 2019 21:23
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 reime005/65cdaae615f86b0f23d292336fea135c to your computer and use it in GitHub Desktop.
Save reime005/65cdaae615f86b0f23d292336fea135c to your computer and use it in GitHub Desktop.
JavaScript hoisting example
foo(); // works because hoisted
var someVariable = 42;
// would not be hoisted: var foo = function() ...
function foo() {
console.log(someVariable); // undefined
var someVariable = 91;
console.log(someVariable); // 91
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment