开发学院

您的位置:首页>教程>正文

教程正文

ES6 Array对象方法concat()

ES6 Array对象方法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