instance method Function#curry

View source on GitHub →

Function#curry(args...) → Function
  • args (?) – The arguments to curry.

Curries (burns in) arguments to a function, returning a new function that when called with call the original passing in the curried arguments (along with any new ones):

function showArguments() {
  alert($A(arguments).join(', '));
}
showArguments(1, 2,, 3);
// -> alerts "1, 2, 3"
 var f = showArguments.curry(1, 2, 3);
f('a', 'b');
// -> alerts "1, 2, 3, a, b"

Function#curry works just like Function#bind without the initial context argument. Use bind if you need to curry arguments and set context at the same time.

The name "curry" comes from mathematics.