Skip to content

Instantly share code, notes, and snippets.

@EteimZ
Created January 31, 2023 07:58
Show Gist options
  • Select an option

  • Save EteimZ/35617fbc13e6bd6c5b5f3da2fa2550c8 to your computer and use it in GitHub Desktop.

Select an option

Save EteimZ/35617fbc13e6bd6c5b5f3da2fa2550c8 to your computer and use it in GitHub Desktop.
Basic explanation of currying.
// 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