Curry

Currying is a good way to process multiple arguments flexibly. It allows us to produce a new function by combining a function and an argument: JavaScript does not have a curry method, we can fix that by augmenting Funcion.prototype.

    Function.method('curry', function(){
        var args = arguments, that = this;
        return function(){
            return that.apply(null, args.concat(arguments));
        };
        })

    var add1 = add.curry(1);
    document.writeln(add1(6));  // 7

The curry method works by creating a closure that holds that original function and the arguments to curry. It returns a function that, when invoked, returns the result of calling that original function, passing it all of the arguments from the invocation of curry and the current invocation. It uses the Array concat method to concatenate the two arrays of arguments together.