js 复制数组 用 arr.concat()
例子:
var arr1 = [1, 2, 3];
var arr2 = arr1.concat();
arr1[0] = 5;
console.log( arr2 ); // 结果为 [1, 2, 3]
-----------------------------------------------------------
不能用等号复制数组,如:
var arr1 = [1, 2, 3];
var arr2 = arr1;
arr1[0] = 6;
console.log( arr2 ); // 结果为 [6, 2, 3]