function add(x,y,z){
console.log('结果',x+y+z);
};
function curry(fn){
let args = [].slice.call(arguments,1);
let len = fn.length;
let newLen = args.length;
if(newLen == len){
return fn.apply(this,args);
}
if(newLen > len){
console.log('参数传递多了...');
}
function loop(){
args.push(...arguments);
newLen += arguments.length
i f(newLen == len){
return fn.apply(this,args);
}
if(newLen > len){
console.log('参数传多了...');
}
return loop;
}
return loop;
}
curry(add,2,1)(2);
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)