title: Javascript: interpret string as object reference?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/6084858/javascript-use-variable-as-object-name">Javascript use variable as object name</a>  </p>
  </blockquote>
  
  
  
  <p>How do I get JS to treat a string as a reference to a previously defined object? Simplified:</p>
  
  <pre><code>var myObject = new MyObject();
  
  var myString = "myObject";
  
  var wantThisToWork = myString.myproperty;
  </code></pre>