title: How do I store an array of objects?
body: <p>I have an object <code>image</code> I can do things like <code>image.top</code> and it will return a value, or I can do <code>image.myPoints[0].left</code> and it will return a value.  I basically have this image object that stores values for me.  I want to be able to put multiple <code>image</code> objects in an array so i could do something like this:</p>
  
  <pre><code>$("#toPinpoint").mapImage({
                  useAjax: false,
                  pinpoints: [ { "top": 50,
                             "left": 280,
                             "width": 200,
                             "height": 200},
                           { "top": 0,
                             "left": 0,
                             "width": 300,
                             "height": 74 } ] 
              });
  </code></pre>
  
  <p>I use this function to create the object, the pinpoints get added on to the object.  When the mapImage function is called this is what happens:</p>
  
  <pre><code>    $.fn.mapImage = function(options){
  
  
  
      //Set user input options and defaults
      var optionConfig = $.extend({}, $.fn.mapImage.defaults, options);
  
      image=this;
      this.image = this;
  
      // Assign defaults
      this.previewMode = optionConfig.previewMode;
      this.pinpoints = optionConfig.pinpoints;
      image.pinpoints = optionConfig.pinpoints;
      image.pinpointCount = 0;
      image.selected = 0;
      ...}
  </code></pre>
  
  <p>This sets the image properties and now I want to modify the properities with my application then SAVE these <code>image</code> objects into an array.</p>
  
  <p>My problem with this is that the array is loading up with image objects, but it seems to fill the whole array with the object i just pushed in, so it doesnt save my old image objects. For example, if i do <code>myArray[0].myPoints[0].left</code> , lets say it retruns 30, and then i push another image object that has myPoints[0].left equal to 20, the first image object I have in the array turns into 20 instead of saving it as 30.  If theres a good way of solving this issue it would be greatly appreciated.  Thank you!</p>