Skip to content

Instantly share code, notes, and snippets.

@ChaelCodes
Last active September 8, 2021 22:35
Show Gist options
  • Save ChaelCodes/f034f71595b6658d231bc7f4fad11852 to your computer and use it in GitHub Desktop.
Save ChaelCodes/f034f71595b6658d231bc7f4fad11852 to your computer and use it in GitHub Desktop.
When you curry a function, you can skip arguments when calling the function. Curry will wait until all arguments are present to attempt calling the function. This lets you define functions that supply an argument or two, and then call those functions with the rest of the arguments later.
// The function is curried, so we can skip a or b
const add = curry((a, b) => a + b);
// These functions use a curried function, so you can skip an argument
const increment = add(1);
const addTen = add(10);
// The function is now called because the second argument is supplied
addTen(5); // returns 15
increment(3); // returns 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment