Created
May 23, 2014 15:55
-
-
Save mojaray2k/736836a32b62a83f30c9 to your computer and use it in GitHub Desktop.
To use partial application, you need to first bind the function to a context. After that, passing in additional parameters to the .bind() call withholds those parameters and applies them when the bound function is called.
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
function add(a, b){ | |
return a + b; | |
} | |
var addOne = add.bind(null, 1); | |
var result = addOne(2); | |
console.log(result); //=> 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment