In function2 and function3, you're modifying the input variable (by changing its contents).
In function1, you're not modifying the input variable; you're merely assigning it to point to something else with =
.
Objects (including arrays) are passed by reference - if you don't want to modify the input, the safest thing to do is make a copy of the input at the beginning of the function (before potentially modifying it). For arrays, you can do this with the slice
function: var copy = input.slice(0)