SOURCE

function partial(fn, ...rest) {
    let argsLength = fn.length
    return function(...args) {
        return fn.apply(this, rest.concat(args))
    }
}

/** 测试代码 */
let testFn = function(a, b, c, d) {
    return [a, b, c, d]
}

let testFnPartial = partial(testFn, 10, 15)
console.log(testFnPartial(20, 30))
console.log(testFnPartial(40, 30))
console 命令行工具 X clear

                    
>
console