javascript将数组插入到另一个数组中

将数组arr2插入到数组arr1的index位置:

var arr1 = ['a', 'b', 'c'];
var arr2 = ['1', '2', '3'];
var index = 1;
arr2.unshift(index, 0);
Array.prototype.splice.apply(arr1, arr2); console.log(arr1);

显示结果:

["a", "1", "2", "3", "b", "c"]

 

 

posted @ 2012-12-05 18:37  zhaoran  阅读(381)  评论(0编辑  收藏  举报