let\'s say I\'ve got an array, var animals = [\"dog\",\"cat\",\"rat\"];
var animals = [\"dog\",\"cat\",\"rat\"];
then I define var pets = animals;
var pets = animals;
then I call pets.shift(
pets.shift(
You have to clone the array, which is done with
var savedAnimals = animals.slice();
Note that this isn't a deep clone : it doesn't protect the elements inside against modification (if they're not strings).