jQuery Deconstructed. Creating a jQuery like chaining API - Buymeasoda. I was curious how jQuery created it's chaining API, wrapping up the matched DOM nodes in the return object.
It's a nice pattern that would be useful to use in other scripts. When called, the jQuery object returns an object built using the constructor invocation pattern. The jQuery methods that operate on the matched node set are exposed via the constructors prototype object, making them available through the prototype chain. The setup code also stores a reference to the prototype object in jQuery.fn, which makes it easy to add new methods later via jQuery.prototype or jQuery.fn, which refer to the same thing. The jQuery constructor pattern. Building your own JavaScript library 1. Goal There are two programming languages I like: PHP and Javascript. In this mini series, I will explore Javascript and jQuery, and build my own library/framework. I won't re-invent the wheel here.