不知道可否有人试过复制多维数组变量后,修改原来的数组变量,而拷贝的变量值也一起更换呢?
如:
var = new Array([1,2]);
var = myArray;
myArray[0][0] = 3;
trace(myArray); //3,2
trace(temp); //没更动但却输出3,2
而经过测试之后,在一维数组却没有问题。所以从此处写出修正的方法
= function(){
var a = [];
for (var i in this) (this[i] instanceof Array) ? a[i] = this[i].slice() : a[i] = this[i];
return a;
}
var = new Array();
myArray[0]=[1,2]
myArray[1]=3
myArray[2]=[5,6]
var = ();
trace(myArray); //1,2,3,5,6
trace(temp); //1,2,3,5,6
myArray[0][0] = 5;
trace(myArray); //5,2,3,5,6
trace(temp); //1,2,3,5,6