title: Javascript: Add key/value pairs in nested dict; key and value are variables
body: <p>I have a dictionary of the following structure:</p>
  
  <pre><code>myDict = {key1:{innerKey1:innerValue1, innerKey2:innerValue2}, key2:{},...}
  </code></pre>
  
  <p>Based on:
  <a href="https://stackoverflow.com/questions/1168807/how-can-i-add-a-key-value-pair-to-a-javascript-object">How can I add a key/value pair to a JavaScript object?</a> </p>
  
  <p>I tried to add inner key/value pairs like this:</p>
  
  <pre><code>someArray=['foo','bar']
  var identifier = someArray[0]
  var info = someArray[1]
  myDict[key1][identifier] = info;
  </code></pre>
  
  <p>Or like this:</p>
  
  <pre><code>myDict[key1].identifier = info;
  </code></pre>
  
  <p>But I get the error <strong>'cannot set property of undefined'</strong>. I think this is due to the identifier not being defined in myDict yet, but I cannot figure out how to achieve this:</p>
  
  <pre><code>myDict = {key1:{innerkey1:innerValue1, innerKey2: innerValue2, foo:bar,...}, key2:{},...} 
  </code></pre>
  
  <p>Please note: I know in this example the assignment of variables is not necessary. I need to figure out the concept for a bigger, more complex project and this is the minimum "non-working" example.</p>
  
  <p>Thanks in advance :)</p>