Jquery source code - merge shallowly clone two arrays (class array);

source and application:


    function merge(first , second) {
       var i = first.length;
       var len = i + second.length;
       var j = 0;
       for(; i < len; i++){
           first[i] = second[j++];
       }
       first.length = len;
       return first;
    }
    var arr = [1,2,3,4,{test: 1}];
    var larr = {
        0: 1,
        1: 2,
        2: 3,
        test: function () {
            console.log(111);
        },
        length: 3
    };
    // console.log(merge(arr,larr));
    // [1,2,3,1,2,3];
    console.log(merge(larr,arr));
    // larr = {
    //     0: 1,
    //     1: 2,
    //     2: 3,
    //     3: 1,
    //     4: 2,
    //     5: 3,
    //     6: 4,
    //     test: function...
    //     length: 7
    // }

shallow clone, if there is a reference value in the clone body, changing the clone will change the cloned object; If you change arr[4].test will change larr;