title: Getting references to local variables created during eval() in JavaScript
body: <p>In the scenario below, how can I get references to the variables declared during eval() if I do not know their names?</p>
  
  <pre><code>function test() {
    eval("var myVariable = 5");
    var locals = magic() // TODO What should we do here?
    alert(locals["myVariable"]); // returns myVariable
  }
  </code></pre>
  
  <p>Just a note: JavaScript being evaluated comes from a trusted source.</p>