let currying= (fn, ...args) =>{
? ? let _args= args || [];
? ? return (...rest)=>{
? ? ? ? _args.push(...rest);
? ? ? ? if(rest.length === 0){
? ? ? ? ? ?return fn.apply(this, _args)
? ? ? ? }else{
? ? ? ? ? ? return currying.call(this, fn, ..._args)
? ? ? ? }
? ? }
}
const result = currying((...rest) => {
? ?return rest.reduce((a,b) => a+b)
})
result(1,3)(3)()
function add() {
? ? const _args = Array.prototype.slice.call(arguments);
? ? const _adder = function() {
? ? ? ? _args.push(...arguments)
? ? ? ? return _adder
? ? }
? ? _adder.toString = function () {
? ? ? ? return _args.reduce(function (a, b) {
? ? ? ? ? ? return a + b
? ? ? ? })
? ? }
? ? return _adder
}
+add(1)(2)(3)(4)(5)