I've been wondering if it's possible to "save" or "compile" a jQuery function chain. That is, I don't want to apply it to a DOM set outright, but at a later time:
$custom = $.show().addClass("whatever").other_things();
So above statement doesn't select anything $("#..") itself. Instead it "assigns" (?) the chain to a temporary var, which I could later use:
$custom("article");
or maybe:
$("article").apply($custom);
Obviously there isn't such a thing in jQuery. And for most use cases you could just define an ordinary function with the reusable filter/effect chain; or use callbacks like in effect chains. But suppose I had use for such a handy shortcut over defining multiple workaround functions.
So, would it technically be possible to "capture" a function call list like that in Javascript?
Can Javascript detect function calls, is there something like e.g. __call__ in Python?
(Which would allow to record function calls in some list like [[show, {}], [addClass, "whatever"], [otherthings, {}]].)
G!