function sum(a, b, c) {
return a + b + c
}
function curry(f) {
return function fn(...args) {
if (args.length >= f.length) {
return f.apply(this, args)
} else {
return function (...args2) {
return fn.apply(this, args.concat(args2))
}
}
}
}
const sc = curry(sum)
console.log(sc(1, 2, 3))
console.log(sc(1)(2, 3))
console.log(sc(1, 2)(3))
标签:function,return,log,args,js,柯里化,sc,console
From: https://www.cnblogs.com/samsara-yx/p/16799770.html