Skip to content

Instantly share code, notes, and snippets.

@sym3tri
Created February 26, 2015 22:54
Show Gist options
  • Save sym3tri/3bddc8c3719fd484536a to your computer and use it in GitHub Desktop.
Save sym3tri/3bddc8c3719fd484536a to your computer and use it in GitHub Desktop.
example of how javascript hoisting works
function foo() {
var myvar = 'my value';
(function() {
alert(myvar); // undefined
var myvar = 'local value';
})();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment