I was looking over the jQuery to better understand how it works. The constructor basically just calls
new jQuery.fn.init
I was wondering w
$() is an instanceof (new $()) is an instanceof (new $.fn.init())
The technique employed by jQuery is how you can achieve this. $() always returns as if it was called with the new keyword. However, instead of using a conditional switch on the this reference inside function jQuery() {...} it uses an external delegate object in all cases. This external delegate object, jQuery.fn.init() {...}, is given the jQuery prototype so that its object 'type' is of jQuery, and that all instances of it are actually instances of jQuery.