SOURCE

function curry(fn) {
  if (fn.length <= 1) return fn;
  const generator = (...args) => {
    if (fn.length === args.length) {
      return fn(...args);
    } else {
      return (...args2) => {
        console.log('=========== args2', args, '|', args2);
        return generator(...args, ...args2);
      }
    }
  }
  return generator;
}

let add = (a, b, c, d) => a + b + c + d;
const curriedAdd = curry(add);
curriedAdd(5)(6)(7)(8);
console 命令行工具 X clear

                    
>
console