title: Can not add key dynamically in Javascript Object
body: <p>I am trying to add a key dynamically to an obj but I keep getting error "<strong>Can not set property of undefined</strong>" 
  But I cant decalre these properties before knowing them. I want them to added dynamically as a key to that object.    </p>
  
  <pre><code>var dict = {}
   objectarray.forEach((item: Obj) =&gt; {
          this.dict[item.ID] = "xyz";
      });
  </code></pre>
  
  <p>As per <a href="https://stackoverflow.com/questions/695050/how-do-i-add-a-property-to-a-javascript-object-using-a-variable-as-the-name">How do I add a property to a Javascript Object using a variable as the name?</a> it seems possible to add property to object dynamically just by using obj[name] = value.</p>
  
  <p>Am I missing something ? Any help ?</p>