Looking at the fallowing structure of an older jQuery version:
(function( window, undefined ) {
var jQuery = (function() {
var jQuery = function( selector, context ) {
return new jQuery.fn.init( selector, context );
};
jQuery.fn = jQuery.prototype = {
init: function( selector, context ) {
// ...
return this;
}
// jQuery API methods
}
// Give the init function the jQuery prototype for later instantiation
jQuery.fn.init.prototype = jQuery.fn;
return (window.jQuery = window.$ = jQuery);
})();
})(window);
it is quite easy to understand that:
jQuery.fn = jQuery.prototype = {
init: function( selector, context ) {
return this;
}
}
jQuery.fn.init.prototype = jQuery.fn;
is the one section that fires when jQuery is called with normal usage as for example
$('p')
or
jQuery('p')
it is really not clear how is it possible to call API methods with the form $.ajax()
or $.isArray()
and where would you place, lets say, a custom method within the listed code and call it with $.myCustomMethod().
Any help will be very much appreciated.