At first I thought it was just assigning obj[0], obj[1], obj[2], etc. to the jQuery object before returning it, and that the length is manually assigned. But no, since console.log logs an array and not an object.
I took a quick look at the jQuery source but since I’m not familiar with it I didn’t crack it easily. jQuery.makeArray popped first, but it turned out to be the opposite of what I’m looking for, you actually lose the object methods by using it.
My first guess is initiating the array first, and then copying all the properties and methods from the object to it.
Does anybody with the jQuery source code experience have a clear answer to this?
It’s as simple as creating a new function and assigning it a new array as its prototype.
So for example:
http://jsfiddle.net/Xeon06/fUgaf/