merge: function( first, second ) {
var i = first.length, j = 0; if ( typeof second.length === "number" ) {   //
for ( var l = second.length; j < l; j++ ) {
first[ i++ ] = second[ j ];
}

} else {
while ( second[j] !== undefined ) {
first[ i++ ] = second[ j++ ];
}
} first.length = i; return first;
}
jquery 里的meger就去: 是不是second 的性情全部copy 到first 里去,但如果是对象呢,也用 first[ i++ ] ,类似用数数组

解决方案 »

  1.   


    lz在研究jquery的底层吧,记得上一次也是问jquery底层代码的
    底层的代码是将数组2的元素添加的数组1中,数组中存放的对象也是被++添加到数组1中的
      

  2.   


    1:
    在看点源代码,上面的方法就是把second  copy  到first上去  这样的话 second  的属性在 first都是已数字作为其属性名了2:
    突然 看到 $("input[dataType]") 这用法,我想是 input 里有属性dataType不为空的input 但在api 
    上,找到 $('input[attr="dataType"]')//假设attr= dataType
    难道用#('')查找时,没有属性名(如上面的$("input[dataType]")),就是找input 里有属性值为
    dataType的元素,但在api 上没找这用法呀