Skip to content

Instantly share code, notes, and snippets.

@nulayuhz
Created January 27, 2015 03:00
Show Gist options
  • Save nulayuhz/1108efeaf7579abf2fb9 to your computer and use it in GitHub Desktop.
Save nulayuhz/1108efeaf7579abf2fb9 to your computer and use it in GitHub Desktop.
function declaration vs function expression
function expression:
foo() //try to call foo TypeError!
var foo = function () {
// do something
};
is more like:
var foo;
foo() //try to call foo TypeError!
foo = function() {
// do something
}
the variable (name identifier is hoisted), but the assignment is not;
function declaration:
foo();
function foo() {
// no problem!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment