Objects, including arrays are assigned by reference in ECMAScript. So, when you modify the array in the function you are modifying the same array as you passed into the function, not a new copy of the array.
A quick way to perform a shallow copy of an array is using slice(0) (and in some modern engines you can leave out the 0). See this answer about copying an array.
Also see this answer for some examples.