Skip to content

Instantly share code, notes, and snippets.

@lqt0223
Created July 7, 2023 12:18
Show Gist options
  • Save lqt0223/df294231d52f085efa8d64ca147c6967 to your computer and use it in GitHub Desktop.
Save lqt0223/df294231d52f085efa8d64ca147c6967 to your computer and use it in GitHub Desktop.
39 currying
function curry(fn) {
return function curried(...args) {
if (args.length >= fn.length) {
return fn.call(this, ...args)
} else {
return curried.bind(this, ...args)
}
}
}
const _add3 = (a, b, c) => a + b + c
const add3 = curry(_add3)
// console.log(add3(1)(2)(3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment