Last active
January 25, 2018 08:56
-
-
Save xiaoyunyang/2a85a0b60cad418c9136e97df63245ac to your computer and use it in GitHub Desktop.
JavaScript Currying
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
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