Partial application in JavaScript?

I’ve been learning more about functional programming lately, and after seeing a few interestingthings on the interwebs, I decided to spend a little more time experimenting with partial application in JavaScript.

Now, I’m far from an expert in functional programming. What I’ve done here seems strange and exciting to me, and I have absolutely no idea how I would use it, or even what it’s called.

Note that an in-depth follow-up to this article titled Partial Application in JavaScript has been published, so check that out if you want to know the actual difference between partial application and currying!

The new

In the following code sample, invoking the curried function will always return a function until all arguments are satisfied, at which point the original function is invoked, returning its result. This means that all function arguments are required, which also allows the function to be called either like foo( 1, 2, 3 ) or foo( 1 )( 2 )( 3 ). This also means that if any argument is omitted, the original function is never invoked.

The “knew”

Contrast that with this partial application approach (which I had incorrectly learned as “currying”). Invoking the partially applied function will always invoke the original function, and if any arguments are omitted, they are simply undefined. This allows for any number of arguments, but must be called like foo( 1, 2, 3 ) and not foo( 1 )( 2 )( 3 ).

Questions, questions

I’d only ever seen partial application done like in the above partial function until recently, but a strange and confusing new world has been opened up to me here.. so, that being said, while the curry pattern is interesting, can I do anything useful with it?

Use &lt; instead of < and &gt; instead of > in the examples themselves.

Partial application in JavaScript?

I've been learning more about functional programming lately, and after seeing a few [interesting](http://gist.github.com/576723) [things](http://jsfiddle.net/t8cAK/2/) on the interwebs, I decided to spend a little more time experimenting with [partial application](http://en.wikipedia.org/wiki/Partial_application) in JavaScript.\n\nNow, I'm far from an expert in functional programming. What I've done here seems strange and exciting to me, and I have absolutely no idea how I would use it, or even what it's called.\n\nIs this partial application? Currying? Something else? (Vindaloo maybe?)\n\n

\n Note that an in-depth follow-up to this article titled Partial Application in JavaScript has been published, so check that out if you want to know the actual difference between partial application and currying!\n