title: Javascript - use an array for object names then grab properties using a loop
body: <p>Going crazy trying to do this so I thought I'd get help. I have an array like this:</p>
  
  <pre><code>OBJECTS = ["mainmenu","mainviewer","mainsearch"];
  </code></pre>
  
  <p>Each of these is an object like this:</p>
  
  <pre><code>mainmenu = {width:250,height:250,backgroundcolor:red};
  mainviewer = {width:250,height:250,backgroundcolor:green};
  mainsearch = {width:250,height:250,backgroundcolor:blue};
  </code></pre>
  
  <p>Now the crux of it ... I'm simply trying to get the properties like this:</p>
  
  <pre><code>for (var item in OBJECTS) {
      var name = OBJECTS[item];
      console.log("the width of "+name+" is "+name.width);
  }
  </code></pre>
  
  <p>The console logs back to me:</p>
  
  <pre><code>the width of mainmenu is undefined
  </code></pre>
  
  <p>Any help greatly appreciated ...</p>