Js函数柯里化
函数柯里化是什么?
函数柯里化是这样的一个转换过程,把接受多个参数的函数变换成接受一个单一参数(注:最初函数的第一个参数)的函数,如果其他的参数是必要的,返回接受余下的参数且返回结果的新函数。
实现代码:
function curry(func){
var args = [].prototype.slice.call(arguments,1),self = this;
return function(){
var newArgs = args.concat([].prototype.slice.call(arguments,0));
func.apply(self,params);
}
}-
支付宝 -
微信


