1 function (callback, args) { 2 return Jquery.each (This, callback, args); 3 },
Each: This invokes the Jquery.each method, which iterates through the current collection. Let's look at the Jquery.each method first:
//args is an arrayeachfunction(obj, callback, args) {varvalue, I= 0, Length=Obj.length, IsArray=isarraylike (obj); if(args) {if(IsArray) {//if the object being traversed is an array then the element is traversed by the subscript for(; i < length; i++) {Value=callback.apply (Obj[i], args); if(Value = = =false) { Break; } } } Else { //if the target of the traversal is not an array, iterate through the object members by enumerating the objects for(Iinchobj) {Value=callback.apply (Obj[i], args); if(Value = = =false) { Break; } } } //A Special, fast, case for the most common use of each //if no args array is passed in}Else { if(IsArray) {//if the object being traversed is an array then the element is traversed by the subscript for(; i < length; i++) {Value=Callback.call (Obj[i], I, obj[i]); if(Value = = =false) { Break; } } } Else { //if the target of the traversal is not an array, iterate through the object members by enumerating the objects for(Iinchobj) {Value=Callback.call (Obj[i], I, obj[i]); if(Value = = =false) { Break; } } } } returnobj;},
The entire method structure is still very clear. In accordance with the args array there is no incoming divided into two branches, each branch in accordance with the traversal of the target is an array or an object is divided into two small branches. With the argument args, the callback method is called on each element that is traversed and passed in the parameter args. If there is no parameter args, then the callback actually passed in is the current sequence number I and the element itself, which is the invocation form we often use, such as $ (". Class"). each (function (i,e) {}).
In fact, I would like to emphasize that everyone should not just think that each method is only a regular use of each (function (i,e) {}) this form OH. In fact, each inside callback can take an array of parameters, but then remember that callback parameters can be not the number + current element ah.
Rookie of the jquery source learning notes (iii)