SOURCE

function currying (fn, length) {
    length = length || fn.length;
    return function (...args) {
        if (length <= args.length) {
            return fn(...args);
        } else {
            return currying(fn.bind(this, ...args), length - args.length);
        }
    }
}

function test(a, b, v) {
    return a + b + v;
}

const curryingAdd = currying(test);
console.log('2222', curryingAdd(1, 3)(2));

const func = test.bind(this, 2, 3);
console.log('333', func(4));
console 命令行工具 X clear

                    
>
console