Last active
July 2, 2016 14:12
-
-
Save mariyadiminsky/9fc086960ac2b965ede9af1a9a177883 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
// #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(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think line 29 should be:
asyncfn1().then(() => asyncfn2()).then(() => asyncfn3()).done(() => done());
Right? :)