Created
January 31, 2023 07:58
-
-
Save EteimZ/35617fbc13e6bd6c5b5f3da2fa2550c8 to your computer and use it in GitHub Desktop.
Basic explanation of currying.
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
| // create a curried function | |
| const introSelf = lastName => firstName => console.log(`My name is ${firstName} ${lastName}`) | |
| // use curried function | |
| introSelf("Youdiowei")("Eteimorde") | |
| // Output: My name is Eteimorde Youdiowei | |
| // partially apply the curried function to create a new one | |
| const introDoe = introSelf("Doe") | |
| // use partial function | |
| introDoe("John") | |
| // Output: My name is John Doe | |
| introDoe("John") | |
| // Output: My name is Jane Doe | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment