title: How to load an array of objects in typescript
body: <p>How do i convert this simple javascript to proper typescript syntax using a class with an "Add" method?</p>
  
  <pre><code>var i, rec;
  var myArray = [];
  for (i = 0; i &lt; 10; i++) {
      rec = { name: "john", age: i };
      myArray.push(rec);
  }
  </code></pre>
  
  <p>I figured out how to at least define a variable, but I can't use an "Add" method to load it:</p>
  
  <pre><code>var myArray: { name: string; age: number }[] = [];
  </code></pre>
  
  <p>Here is my pathetic attempt with an Add method on a class:</p>
  
  <pre><code>class MyClass {
      name: string;
      age: number;
  
      add(inArg1: string, inArg2: number) {
          this.name = inArg1;
          this.age = inArg2;
      }
  }
  
  var myArray= new Array&lt;MyClass&gt;();
  
  for (i = 0; i &lt; 10; i++) {
      myArray.add("john", i);
  }
  </code></pre>