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 the constructor returns 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. Take a look at the following concise simulation to understand:
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 names 0, 1, 2 in the Jquery.each ... circular index, It is convenient 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)
<div id= "Div1" ></div>
<script>
Function A () {
this[0] = ' Hello ';
this[1] = ' world ';
this[2] = document.body;
This[3] = document.getElementById ("Div1");
this.length = 4;
return this;
}
//Here is very casual, the function is all right, take a look at the following several, optional:
A.prototype.splice = function () {};//Generally this is the way to get a null function
A.prototype.splice = Window.moveto; Want to make people dizzy, you can deliberately this way
A.prototype.splice = A;//meaningless, save code
A.prototype.splice = [].splice; //jquery is used for this trick, This is also a closed jquery method, the unknown said.
Var a=new a ();
Console.debug (a);
</script>