SOURCE

const curry = function(fn) {
    const len = fn.length;
    const args = [];
    return function() {
        Array.prototype.push.apply(args, arguments);
        const argsLen = args.length;
        if (argsLen < len) {
            return arguments.callee;
        }

        return fn.apply(fn, args);
    } 
}

const add = function(a, b, c) {
    return a + b + c;
}

const adder = curry(add);
console.log(adder(1)(2)(3));

const curryNew = function(fn) {
	const func = function() {
		const _args = [].slice.call(arguments, 0);
		const func1 = function() {
			[].push.apply(_args, arguments)
			return func1;
		}
		func1.toString = func1.valueOf = function() {
			return fn.apply(fn, _args);
		}
		return func1;
	}
	return func;
}

const adderNew = curryNew(add);
console.log(adderNew(1)(2)(3)(5));
console 命令行工具 X clear

                    
>
console