Skip to content

Instantly share code, notes, and snippets.

@ryanflorence
Last active August 29, 2015 14:15
Show Gist options
  • Save ryanflorence/023b84f2002a39ae6c53 to your computer and use it in GitHub Desktop.
Save ryanflorence/023b84f2002a39ae6c53 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 () {}
}
@ryanflorence
Copy link
Author

ha, well, I think I'll limit it to actual code you would write on a day-to-day basis :P

@tazsingh
Copy link

:)

@anthonybrown
Copy link

Nice gist

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