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))