首页 > 代码库 > jQuery.merge()

jQuery.merge()

今天学习seajs,遇到return $.merge([‘module1‘], $.merge(m2.run(), m3.run()));不明白啥意思,上网查了一下明白了,记录一下

jQuery.merge( first, second ) 返回: Array

描述: 合并两个数组内容到第一个数组。

  • version added: 1.0jQuery.merge( first, second )

    first第一个用来合并的数组,元素是第二数组加进来的。

    second第二个数组合并到第一,保持不变。

  • Examples:

    Example: Merges two arrays, altering the first argument.

    $.merge( [0,1,2], [2,3,4] )

    Result:

    [0,1,2,2,3,4] 

    Example: Merges two arrays, altering the first argument.

    $.merge( [3,2,1], [4,3,2] )  

    Result:

    [3,2,1,4,3,2] 

    Example: Merges two arrays, but uses a copy, so the original isn‘t altered.

    var first = [‘a‘,‘b‘,‘c‘];var second = [‘d‘,‘e‘,‘f‘];$.merge( $.merge([],first), second);      

    Result:

    ["a","b","c","d","e","f"] 

jQuery.merge()