function curry(fn,...args){
let len = fn.length;//函数参数长度
return len<=args.length ?
fn(...args)
: (...newArgs)=>curry(fn,...args,...newArgs);
}
function mycurry(fn,...args){
let len = fn.length;//函数参数长度
var args = args||[]
return function(){
let newargs = [].slice.apply(Array.from(arguments));
args.push(...newargs);
if(args.length>=len){
return fn(...args)
}
else{
return mycurry(fn,...args);
}
}
}
function createCurry(func, args) {
var argity = func.length;
var args = args || [];
return function () {
var _args = [].slice.apply(arguments);
args.push(..._args);
if (args.length < argity) {
return createCurry.call(this, func, args);
}
return func.apply(this, args);
}
}
function prinargu(a,b,c,d){
console.log(a,b,c,d)
}
let tmp = mycurry(prinargu);
tmp(1,2)
tmp(4)
tmp(5)
// tmp(2)
// let zjcu = createCurry(prinargu)
// zjcu(1)(2)(3)
// zjcu(1)
// zjcu(2)
console