title: Construct object name, then pass object to function?
body: <p>I'm working on existing Javascript code, which uses datasets stored in objects which are named data1, data2, etc. The numbers are IDs taken from a database.</p>
  
  <p>Now, I need to write a little additional function which takes the IDs as input, then constructs the appropriate object name using that Id, and then passes that object to a function as a parameter.</p>
  
  <p>So, something like:</p>
  
  <pre><code>function doStuff(id){
      var objname="data"+id;
      //now, I need to pass the object (not just the name) to a function
      someFunction(objname);    //this obviously doesn't work, because it just passes the object name as a string
  }
  </code></pre>
  
  <p>So, how do I pass the actual object to the function, given that I have the object name?</p>
  
  <p>The question sounds elementary, and I assume there's a method which does just this, but google doesn't seem to help.</p>