title: Ways to call a Javascript function using the value of a string variable?
body: <p>I've seen this technique for calling a Javascript function based on the value of a string variable.</p>
  
  <pre><code>function foo() {
      alert('foo');
  }
  
  var test = 'foo';
  
  window[test]();  //This calls foo()
  </code></pre>
  
  <p>Is this the accepted way to do it or is there a better way?  Any cross-browser issues to worry about?</p>