Last active
November 24, 2016 07:31
-
-
Save simontegg/8efbc771ef8b4c345134fac200322bb3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // classic | |
| function sum (a, b) { | |
| return a + b | |
| } | |
| // old-school | |
| var sum = function (a, b) { | |
| return a + b | |
| } | |
| // new kid on the block | |
| const sum = (a, b) => { | |
| return a + b | |
| } | |
| // fancy-pants | |
| const sum = (a, b) => a + b | |
| // even fancier | |
| const square = a => a * a | |
| // hipster | |
| const sum = (a, b) => ( | |
| { total: a + b } | |
| ) | |
| // uber hipster | |
| const sum = ({ a, b }) => | |
| ({ total: a + b }) | |
| // bad-ass rockstar | |
| const sum = (head, ...tail) => | |
| (tail.length ? sum(head + tail[0], ...tail.slice(1)) : head) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment