jquery converts a DOM to an array of objects
1, jquery object (this point) is actually a key-value pair of data collection, a common hashtabel. In a collection, a custom key name can be either a letter or an integer, indexed by {name1: "value1", Name2: "value2"}[name2] and {0: "value1", 1: "value2"}[1] There is no difference, The latter data structure has nothing to do with arrays (array), what about "[document]"?
2, the jquery framework, in which the filter DOM object is stored in the properties of the jquery object while the constructor JQuery.fn.init constructs the jquery object, stores the DOM element data key in the form of 0, 1, 2 ... and defines a length property that is designed to facilitate (compatible) the Jquery.each of manipulating DOM elements. Look at the following concise simulation to understand that:
Jquery.each = function (object, callback, args) {//object can be an array array:[...] can also be objects object:{0:dom1, 1:dom2, 2:dom3 ... length:3+}
for (var i = 0; i < object.length; i + +) {
callback.call ( Object[i], I, arg
}
return Object
}
Jquery.each (this, function (I, ARG) {//Here This is the JQuery object, passing through the key name 0, 1, in the Jquery.each, 2. Circular indexing makes it easy to get each DOM element (DOM object) to handle the manipulation.
method ..... .......
//operations 1 (or bulk operations) DOM elements and returns the JQuery object (this).
}, Arg)
3, the problem is some of the introduction of jquery objects in the tutorial, the key name is 0, 1, 2 ... Data structure that customizes the length attribute is separated from the jquery object called "Class array", the concept of fraught, the superfluous, the fog
<script src= "Http://code.jquery.com/jquery-1.6.2.js" ></script>
<script>
Alert (Object.prototype.toString.call ($ (document)) = = ' [Object Array] '); ???
Alert ($ (document) [0]===document);
</script>