ES6 - concat() 方法



concat() 方法返回一個新陣列,該陣列由當前陣列與一個或多個數組連線而成。

語法

array.concat(value1, value2, ..., valueN);

引數

  • valueN − 要連線到結果陣列的陣列和/或值。

返回值

返回一個新陣列。

示例

var alpha = ["a", "b", "c"]; 
var numeric = [1, 2, 3];
var alphaNumeric = alpha.concat(numeric); 
console.log("alphaNumeric : " + alphaNumeric ); 

輸出

alphaNumeric : a,b,c,1,2,3
廣告
© . All rights reserved.