JavaScript中concat()方法

时间:2022-04-27 08:05:26

concat(参数) 用于数组之间的连接,

arrayObject.concat(arrayX,arrayX,......,arrayX)

如:
var a = [1,2,3];
document.write(a.concat(4,5));
var arr = new Array(3)
arr[0] = "George"
arr[1] = "John"
arr[2] = "Thomas" var arr2 = new Array(3)
arr2[0] = "James"
arr2[1] = "Adrew"
arr2[2] = "Martin" document.write(arr.concat(arr2))
var arr = new Array(3)
arr[0] = "George"
arr[1] = "John"
arr[2] = "Thomas" var arr2 = new Array(3)
arr2[0] = "James"
arr2[1] = "Adrew"
arr2[2] = "Martin" var arr3 = new Array(2)
arr3[0] = "William"
arr3[1] = "Franklin" document.write(arr.concat(arr2,arr3))