https://mp.weixin.qq.com/s?__biz=MzAwNjI5MTYyMw==&mid=2651501763&idx=1&sn=cfe7920ad3a966ef995049cff6bfa1fa&chksm=80f1bd0bb786341dd00ccd2baedaafedbc5cdecc846109f278786fc74929d07c51cc08589959&scene=126&sessionid=1678330049#rd
Curry 化是一种将多参数函数转换为单参数函数的技术
function curry(fn){ return function curried(...args){ if(args.length >= fn.length){ return fn.apply(this, args); } else { return function(...rest){ return curried.apply(this, args.concat(rest)); }; } }; } function add(x, y, z){ return x + y + z; } const curriedAdd = curry(add); console.log(curriedAdd(1)(2)(3));
标签:function,return,函数,args,js,Curry,科里,fn From: https://www.cnblogs.com/angdh/p/17197927.html