JavaScript and callback nesting
- by Jake King
A lot of JavaScript libraries (notably jQuery) use chaining, which allows the reduction of this:
var foo = $(".foo");
foo.stop();
foo.show();
foo.animate({ top: 0 });
to this:
$(".foo").stop().show().animate({ top: 0 });
With proper formatting, I think this is quite a nice syntactic capability. However, I often see a pattern which I don't…