Skip to content

Instantly share code, notes, and snippets.

@mojaray2k
Created May 23, 2014 15:55
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 mojaray2k/736836a32b62a83f30c9 to your computer and use it in GitHub Desktop.
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.
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