Archive for February, 2008

Self-”partially applying” JavaScript functions

Was: self-currying JavaScript functions

I read this nice post on self-currying JavaScript functions, and even though the code to me is not optimal (dispite the low line count), it is improperly named, and it depends on the Prototype JavaScript library (which I really don’t like), it is a very nice script and a very nice idea. The trick in this script is using Function.prototype.length. I didn’t know that this property existed, but after digging a bit I’ve realized, that it has been in ECMAScript at least since 3rd edition (which is the latest edition published in 1999), in JavaScript since v1.1, but only made it into ActionScript by ActionScript 3 (which I haven’t study in as much detail as I have with ActionScript 1 and 2 in relation to my book on basic programming in these versions).

In this post I discuss this property and functionality a bit further, and I implement this function for creating self-”partially applying” functions using both no framework, the MochiKit framework and the Prototype framework.

Read the rest of this entry »