Last active
August 29, 2015 14:15
-
-
Save ryanflorence/023b84f2002a39ae6c53 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 () {} | |
} |
ha, well, I think I'll limit it to actual code you would write on a day-to-day basis :P
:)
Nice gist
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't forget about
new Function("n", "return n + 1;");
!