How to get local variable by its name in JS?
<p>Working example with global var:</p>

<pre>
var example_var = 'global var example';

var x = function(){
    var var_name = 'example_var';
    alert('Global var value is: ' + window[var_name]);
}
</pre>

<p>How can I do same thing with a local variable? Like this (not working example):</p>

<pre>
var x = function(){
    var example_var = 'Local var example';
    var var_name = 'example_var';
    alert('Local var value is: ' + window[var_name]);
}
</pre>
