Skip to content

Instantly share code, notes, and snippets.

@hillarymelville
Created April 6, 2014 02:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hillarymelville/10000687 to your computer and use it in GitHub Desktop.
Save hillarymelville/10000687 to your computer and use it in GitHub Desktop.
Different ways to do the same thing
function funny(p) {
return p;
}
var funny = function (p) {
return p;
}
var funny = function wry(p) {
return p;
}
@isaacs
Copy link

isaacs commented Apr 8, 2014

Not quite the same thing.

The difference is in how they're hoisted, and what the name field is.

See https://gist.github.com/isaacs/10168967. Also threw in new Function(..) to highlight how that one runs in the global scope instead of where it's defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment