var test=[1,2,3,4, 5,6,7];
var arr=test;
arr.splice(2,1);
alert(test);//1,2,4,5,6,7
JS arrays are essentially objects. Therefore, the above source code finally prints 1,2,3,4,5,6. This is because assigning test to arr actually assigns the reference of the array to arr, so operating arr will also
Change the source array.
To implement array cloning, the following methods can be used:
Array.prototype.clone=function(){
return this.slice(0);
}