Skip to content

Instantly share code, notes, and snippets.

@mariyadiminsky
Last active July 2, 2016 14:12
Show Gist options
  • Save mariyadiminsky/9fc086960ac2b965ede9af1a9a177883 to your computer and use it in GitHub Desktop.
Save mariyadiminsky/9fc086960ac2b965ede9af1a9a177883 to your computer and use it in GitHub Desktop.
// #1 ES6: if passing one argument you don't need to include parenthesis around parameter.
var kitty = name => name;
// same as ES5:
var kitty = function(name) {
return name;
};
// #2 ES6: no parameters example.
var add = () => 3 + 2;
// same as ES5:
var add = function() {
return 3 + 2;
};
// #3 ES6: if function consists of more than one line or is an object, include braces.
var objLiteral = age => ({ name: "Usagi", age: age });
// same as ES5:
var objLiteral = function(age) {
return {
name: "Usagi",
age: age
};
};
// #4 ES6: promises and callbacks.
asyncfn1().then(() => asyncfn2()).then(() => asyncfn3()).then(() => done());
// same as ES5:
asyncfn1().then(function() {
asyncfn2();
}).then(function() {
asyncfn3();
}).done(function() {
done();
});
@afuggini
Copy link

afuggini commented Jul 2, 2016

I think line 29 should be:
asyncfn1().then(() => asyncfn2()).then(() => asyncfn3()).done(() => done());
Right? :)

@afuggini
Copy link

afuggini commented Jul 2, 2016

Great articles by the way!

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