Skip to content

Instantly share code, notes, and snippets.

@xiaoyunyang
Last active January 25, 2018 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xiaoyunyang/2a85a0b60cad418c9136e97df63245ac to your computer and use it in GitHub Desktop.
Save xiaoyunyang/2a85a0b60cad418c9136e97df63245ac to your computer and use it in GitHub Desktop.
JavaScript Currying
var multThenAdd = num => {
return mul => add => {
return num * mul + add
}
}
var timesTwoPlusFour = (num) => multThenAdd(num)(2)(4)
timesTwoPlusFour(1) //> 6
timesTwoPlusFour(10) //> 24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment