JSFiddle - React, Tailwind, and code Playground
JavaScript
function curry(func, arity = func.length) {
return function (...args) {
if (args.length >= arity) {
return func(...args);
} else {
return curry(func.bind(this, ...args), arity - args.length);
}
};
}
const multiply = curry((a, b, c) => a * b * c);
console.log(curry(2)(3)(4));