Why does my original object get affected after I "copied" it to a new object?
<p>I have this (sub)object called <code>products.original</code>.</p>

<p>which I then extract to a new object called <code>productArray</code>:</p>

<pre><code>var productArray = [];

productArray = products.original;

/*some calculations here*/

//sort the object by lowest score
productArray.sort(function(a, b) {return a.score - b.score;});
</code></pre>

<p>Finally, I extract the first three cells in <code>productArray</code> to a third object called <code>resultArray</code>:</p>

<pre><code>var resultArray= [];        
resultArray = productArray.splice(0,3);
</code></pre>

<p>To my surprise, this reduces the length of <code>products.original</code> by 3 (the splice). Why? And what do I do to hinder this? Thanks in advance.</p>
