Skip to content

Instantly share code, notes, and snippets.

@simontegg
Last active November 24, 2016 07:31
Show Gist options
  • Select an option

  • Save simontegg/8efbc771ef8b4c345134fac200322bb3 to your computer and use it in GitHub Desktop.

Select an option

Save simontegg/8efbc771ef8b4c345134fac200322bb3 to your computer and use it in GitHub Desktop.
// 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