The If Works This dirt was a building before

Archive for 12 December 2007

Self-currying JavaScript functions

I’m telling you, this language keeps surprising me. You’ll need Prototype for this one. Function.prototype.toSelfCurrying = function(n) { n = n || this.length; var method = this; return function() { if (arguments.length >= n) return method.apply(this, arguments); return method.curry.apply(arguments.callee, arguments); }; }; Make a simple function: var adder = function(a,b,c) { return a + b [...]