SOURCE

function curry(fn) {
    let length = fn.length;
    let args = [];
    return function curryFn(...curryArgs) {
        args = args.concat(curryArgs);
        if (args.length > length) {
            throw new Error('arguments length error')
        }
        if (args.length === length) {
            return fn(...args);
        }
        return curryFn;
    }
}

function add(a, b, c) {
    return a + b + c
}
let res = curry(add)(1)(2)(3)
console.log(res); //6
console 命令行工具 X clear

                    
>
console