javascript locals()?
<p>In python one can get a dictionary of all local and global variables in the current scope with the built-in functions locals() and globals().  Is there some equivalent way of doing this in javascript?  For instance, I would like to do something like the following:</p>

<pre><code>var foo = function(){ alert('foo'); };
var bar = function(){ alert('bar'); };

var s = 'foo';
locals()[s](); // alerts 'foo'
</code></pre>

<p>Is this at all possible, or should I just be using a local object for the lookup?</p>

<ul>
<li><p>locals() - No. </p></li>
<li><p>globals() - Yes.</p></li>
</ul>

<p><code>window</code> is a reference to the global scope, like <code>globals()</code> in python.</p>

<pre><code>globals()["foo"]
</code></pre>

<p>is the same as:</p>

<pre><code>window["foo"]
</code></pre>
