<script>
function sum(a,b,c,d,e){
return a+b+c+d+e
}
const currying = (fn,arg = [])=>(...args)=>(
fn.length === args.concat(arg).length?fn(...args.concat(arg))
:currying(fn,[...args,...arg])
)
const fn = currying(sum)
console.log(fn(1,2)(3)(4)(5))
const fn1 = fn(1)
const fn2 = fn1(2)
console.log(fn2(3,4)(5))
</script>
<script>
Function.prototype.uncurring = function(){
let self = this
return function (){
let obj = Array.prototype.shift.call(arguments)
return self.apply(obj,arguments)
}
}
let push = Array.prototype.push.uncurring()
let cu = {}
push(cu,"sex","shuai")
console.log(cu)
</script>