I knew that jQuery function $("selector") returns an object.
var divTest = $(".test"); // returns object
Array.isArray(divTest); // false
typeof divTest; // "object"
Using this object wrapped by the jQuery function, we can use the API of jQuery.
The point that I cannot understand is how we can access native DOM element(s) using an index in jQuery objects like we do in arrays.
<div class="test first"></div>
<div class="test second"></div>
<div class="test third"></div>
//...
var divTest = $(".test");
console.log(divTest[0]); // <div class="test first"></div>
console.log(divTest[1]); // <div class="test second"></div>
console.log(divTest[2]); // <div class="test third"></div>
I opened the uncompressed jQuery source file. I think this question is related with the following method.
The method jQuery.fn.init returns jQuery.makeArray(selector, this). makeArray is extended from jQuery.
Can someone give comments to help me understand this issue?
makeArray()is evidence that the common jQuery Object isn't an array (otherwise why wouldmakeArray()exist in the first place)