Javascript push() method alters values in a referenced array
<p>So, this is working not as I'd expect it to:</p>

<pre><code>var x = [1,2,3];
var y = x;
y.push(4);
console.log(x);
</code></pre>

<p>I thought it'd log [1,2,3] but it logs [1,2,3,4]! What I need is to have a function that only adds a value to y, not x - I want to be able to mess around with the [1,2,3] array, but also be able to "come back to it" and cancel the changes made. I hope that makes enough sense... </p>
