Partial application refers to the practice of partially filling in a functions parameters with arguments, deferring others to be filled-in at a later time. JavaScript libraries like Underscore facilitate partial function application - but the API isn't for everyone. I, for one, feel icky sprinkling calls to _.partial
and _.bind
throughout my application.
Curried functions (found in Haskell and supported by Scala, among others) can be partially-applied with little ceremony; no special call format is required. In this blog post, I'll demonstrate an approach to currying JavaScript functions at the time of their definition in a way that enables partial function application without introducing lots of annoying parens, anonymous function expressions. This post is mostly for the lulz; I hope it stretches your mind, if nothing else.