I\'ve written the following JavaScript:
var myArray = [\'a\', \'b\', \'c\'];
var copyOfMyArray = myArray;
copyOfMyArray.splice(0, 1);
alert(myArray); // aler
You don't have any copies.
You have multiple variables holding the same array.
Similarly, you have multiple variables holding the same number.
When you write copyOfMyNumber = ...
, you're putting a new number into the variable.
That's like writing copyOfMyArray = ...
.
When you write copyOfMyArray.splice
, you're modifying the original array.
That isn't possible with numbers because numbers are immutable and cannot be modified,