how does javascript currying function actually works?

Viewed 53

i've been having a lot of trouble understand how this currying function actually works and what exactly its doing ?

   Function.prototype.curry = function() {
   var fn = this, args = Array.prototype.slice.call(arguments);
   return function() {
     return fn.apply(this, args.concat(
       Array.prototype.slice.call(arguments)));
   };
 };

because im only familiar with this type of currying function:

function curry(f) { 
  return function(a) {
    return function(b) {
      return f(a, b);
    };
  }
0 Answers
Related