title: how do I name objects dynamically and use object constructor in javascript?
body: <p>I'm pulling data with Ajax that changes every day. I want to package the data into  objects that have unique names. Currently I created a constructor that looks like something like this:</p>
  
  <pre><code>function myObject(Id,thing1,thing2,thing3) 
  {
      this.Id = Id;
      this.thing1 = thing1;
      this.thing2 = thing2;
      this.thing3 = thing3;
  }
  </code></pre>
  
  <p>then I push that to an array in a loop like this</p>
  
  <pre><code>for(var i=0; i&lt;data.length; i++)
  {
      array.push(new myObject(value1,value2,value3,value4));
  }
  </code></pre>
  
  <p>This works fine for what I'm doing but I just get an array with [object,object,object,object] inside of it which I can access with array[0] , array[1], etc.</p>
  
  <p>but now I want to store those objects in firebase and would need to reference them so how could I have them named uniquely?</p>
  
  <p>normally you would do</p>
  
  <pre><code>var thingid1 = new myObject(value1,value2,value3,value4));
  var thingid2 = new myObject(value1,value2,value3,value4));
  </code></pre>
  
  <p>but this is all being created on the fly and sometimes there is 1 object created and sometimes 10.</p>
  
  <p>I'm new at this and I've looked everywhere so any help would be appreciated.</p>