$("foo").stuff().bar().res()
jQuery feels like the list monad, if you see chaining as similar to bind and $() not so far from return.And for Lisp, jquery provided error handlers instead of relying on native try/except.
Of course, it's more inspired from it than the real thing, but it's far from any JS paradigm of the time. Remember that JS didn't even have map() and the only place you used your first class functions was to setInterval. Plus the joke is funnier that way :)
setInterval('console.log(1 + 1)', 1000);
And it works. It's a big eval().Stealing this for my next JS training, beginners always have a hard time with callbacks, so it's a good first step to actually explain the benefits of callbacks.
Once they do, you show the problems with it and show why callbacks are better.
When it comes to pedagogy, I'll use every trick I can.
And I always win.
If your way works, then it works though I suppose.
When I was learning callbacks I saw people use the "setInterval" example and while it did help to an extent, the real world implementation still left a good deal to be desired.
The use of method chaining in jQuery is cool, but it is not very similar to Haskell.
That's what the jQuery API does behind the scene of the chained calls. That's one of the key reasons of its success actually.
$(".foo").foo().bar() will execute n times, for each of the n DOM elements you matched with ".foo", including one or zero.
Yes this is a cool and useful pattern, but it is not bind. It is just a different thing.