title: Iterate through arrays in typescript
body: <p>I want to iterate through an array of objects and acces the property values of that iterated object in typescript.</p>
  
  <p>Doing this in c#, it's just a matter of performing a foreach through the array.</p>
  
  <p>In typescript this seems a bit different. We can do a foreach, but we dont have access to 'complete' object, how to do this? </p>
  
  <pre class="lang-cs prettyprint-override"><code>@Input() gridDefinitions: GridColumnDefinition[]   
   public test() {
       for (var def **in** this.gridDefinitions){
         var test = &lt;GridColumnDefinition&gt;this.selectedObject;
         let castedtype = &lt;GridColumnDefinition&gt;def; // this gives an error
      }  
   }
  </code></pre>
  
  <p>UPDATE: I just ran into the solution. Problems lies in how to iterate through the collection. When using <strong>of</strong> in stead of <strong>in</strong> we can access the iterated object. See <a href="https://stackoverflow.com/questions/12950681/typescript-for-in-statement">TypeScript for-in statement</a></p>