Last active
September 8, 2021 22:35
-
-
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.
This file contains hidden or 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
// 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