How do I store different states of an object in an array?
<p>I have an object called <code>apples</code> and if i do something like <code>apples[0].weight</code> it returns a value.  Now I want to be able to store an array of <code>apples</code>.  Lets call the array <code>myApples</code>.  How do I add multiple instances of <code>apples</code> to the <code>myApples</code> array without the values changing to the most updated one.  For example:</p>

<pre><code>apples[0].weight = 10;
apples[1].weight = 20;
myApples.push(apples);
apples[0].weight = 15;
apples[1].weight = 16;
myApples.push(apples);
</code></pre>

<p>Now if I were to print the value <code>myApples[0].apples[0].weight</code> i get 15 instead of getting 10.  I think its because the reference is the same array, so it gets updated every time I change it.  How would I go about storing these <code>apple</code> "states" so I can keep a history of changes made to it.  Keep in mind I want to make this arbitrary, so I wouldnt have to make something like apples1, apples2, apples3, because the changes on this could be unlimited.(In my actual project I am storing pinpoints on a canvas, so i can basically do an "undo" and "redo" feature and want to store the values of these pinpoints every time something changes on the canvas.)</p>

<p>EDIT-
This is how I make <code>apples</code> or <code>pinpoints</code>:</p>

<pre><code>var options = {pinpoints: [ { "top": 50,
                           "left": 280,
                           "width": 200,
                           "height": 200},
                         { "top": 0,
                           "left": 0,
                           "width": 300,
                           "height": 74 } ]}    
var optionConfig = $.extend({}, $.fn.mapImage.defaults, options);
var myPinpoints = optionConfig.pinpoints;
</code></pre>

<p>So if i do myPinpoints[0].left it gives me 280, I want to be able to push myPinpoints into an array then change myPinpoints[0].left to something else, and then push it on to the array again and save BOTH values</p>
