下面介绍一下如何使用简单的JS代码让多个数组合并。
//第一种方法
var a = [1,2,3];
alert(a.concat([4,5]));
//第二种方法
var Visitor={};
Visitor.push=function(){
return Array.prototype.push.apply(this, arguments);
}
var obj = {};
obj.push =Visitor.push;
obj.push("first","second");
alert(obj[1])
//second
alert(obj.length);
//2