Generic curry function

This is the way one can create generic curry function

function fixCurry(fn, totalArgs){
  totalArgs = totalArgs ||fn.length
  return function recursor(){
  return arguments.length<fn.length?recursor.bind(this, ...arguments): fn.call(this, ...arguments);
  }
}

var add = fixCurry((a,b,c)=>a+b+c);
console.log('Add')

console.log(add(1,2, 3))
console.log(add(1)(2,3))
console.log(add(1)(3)(2))
console.log(add(1,2)(3))

var mul = fixCurry((a,b,c)=>a*b*c);
console.log('Multiple')
console.log(mul(1,2,3))
console.log(mul(1)(2,3))
console.log(mul(1)(3)(2))
console.log(mul(1,2)(3))




Comments