Skip to content

Instantly share code, notes, and snippets.

@davidbgk
Forked from ryanflorence/gist:023b84f2002a39ae6c53
Last active August 29, 2015 14:15
Show Gist options
  • Save davidbgk/1c3a5307a3f1a2fdbc20 to your computer and use it in GitHub Desktop.
Save davidbgk/1c3a5307a3f1a2fdbc20 to your computer and use it in GitHub Desktop.
// declaration
function foo (n) { return n + 1; }
// expression
// note, fat arrow functions have very different meaning (usually what I want, though)
var foo = function (n) { return n + 1; };
var foo = (n) => { return n + 1; };
var foo = n => n + 1;
// object methods
var obj = {
// these are just expressions, but to some beginners they seem different
foo: function (n) { return n + 1; },
foo: (n) => { return n + 1; },
foo: n => n + 1,
// concise method
foo () {}
}
class foo {} // <-- actually just a function
class Thing {
foo () {} // <-- no comma
bar () {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment