How can I get the variable of outer function in Javascript
<p>If only string is allowed to pass into function process(), what should we do inside the function process() to access the array value. Eval is one of the method, but its usage is not suggested by many people.</p>

<pre><code>function demo2(name2)
{
 var alpha = [];
 alpha["a"] = "test1";
 var bravo = [];
 bravo["a"] = "test2"; 

 function process(name)
 {
  alert(window[name]["a"]);
 }
 process(name2); // error
    }
</code></pre>

<p>name2 can be "alpha" or "bravo" or many other arrays' name.</p>

<pre><code>var alpha = [];
 alpha["a"] = "test1";
 var bravo = [];
 bravo["a"] = "test2"; 
    function process(name)
 {
  alert(window[name]["a"]);
 }
    process("alpha");
</code></pre>

<p>For the second example, it works fine.
I just want to pass the string into the function and use it as the array name in the first example. I have the 2nd example and so I would like to know how I can do this inside a function. </p>

<p>What should I write inside the function process to alert the alpha and bravo variables?</p>
