柯里化(currying)函数喂每一个逻辑参数返回一个新函数。对于每一个逻辑参数,柯里化函数会逐渐返回已配置的函数,直到所有的参数用完。
```
['11','11','11','11'].map(parseInt)
// [11, NaN, 3, 4]
```
![](https://img.kancloud.cn/b2/ae/b2ae0dace7b1b74ec628309902ab2424_668x116.png)
```
function curry(fun){
return function (arg){
return fun (arg)
}
}
['11','11','11','11'].map(curry(parseInt)); //[11, 11, 11, 11]
```
![](https://img.kancloud.cn/aa/1b/aa1be9086627c962c62b45d918429919_894x294.png)
```
function curry2(fun){
return function (arg1){
console.log('arg1 50',arg1);
return function (arg2){
console.log('arg2 10',arg2);
return fun (arg1,arg2)
}
}
}
let div = (n,d)=> {
console.log('n 50',n);
console.log('d 10',d);
return n/d
} ;
// let div10 = curry2(div)(50);
// div10(10);
curry2(div)(50)(10);
```