console.log("Arr2 before for: "+Arr2)
console.log("Arr1 before for: "+Arr1)
console.log("Arr1 after for: "+Arr1)
console.log("Arr2 after for: "+Arr2)
When you do
Arr2 = Arr1, you're just copying the reference to that array, you're not making a copy of the array itself. So both
Arr2 will now refer to the same array.
Arr2 = Arr1.slice();
which should copy all of the elements in
Arr1 to the new
Arr2. Check out Array.prototype.slice for more info.