title: Good way to init array of JavaScript objects and their properties?
body: <p>I know I can init an array of JS objects like this:</p>
  
  <pre><code>var things = [
    {
      prop1: 'foo',
      prop2: 'bar'
    },
    {
      prop1: 'foo',
      prop2: 'bar'
    }
  ];
  </code></pre>
  
  <p>I guess I would call these 'anonymous' types (sorry, I'm using C#/.NET language).</p>
  
  <p>What if I want these to be of the same prototype? So I have defined a constructor:</p>
  
  <pre><code>var Thing = function Thing() {
  };
  
  Thing.prototype.prop1 = 'default value';
  Thing.prototype.prop2 = 'default value';
  </code></pre>
  
  <p>Now I want both the items in my original code above to be <code>Thing</code>s.  Is there a good way to do this?</p>
  
  <p>If I were to guess, I would say maybe something like:</p>
  
  <pre><code>var things = [
    new Thing() {
      prop1: 'foo',
      prop2: 'bar'
    },
    new Thing() {
      prop1: 'foo',
      prop2: 'bar'
    }
  ];
  </code></pre>
  
  <p>Which is basically C# object initializer syntax. What I'm trying to avoid is:</p>
  
  <pre><code>var thing1 = new Thing();
  thing1.prop1 = 'foo';
  thing1.prop2 = 'bar';
  var thing2 = new Thing();
  thing2.prop1 = 'foo';
  thing2.prop2 = 'bar';
  var things = [thing1, thing2];
  </code></pre>
  
  <hr>
  
  <p>Edit:</p>
  
  <p>I should also note that my prototypes also contain some functions that are shared. Also in actuality I have arrays nested 3 deep, so its something more like:</p>
  
  <pre><code>{
     [
      { 
        [
          {},
          {}
        ]
      },
      {
        [
          {},
          {}
        ]
      }
    ]
  }
  </code></pre>
  
  <p>Which is why I as hoping to just init everything inline like this and not setting each property line by line.</p>