Getting references to local variables created during eval() in JavaScript
- by David Parunakian
In the scenario below, how can I get references to the variables declared during eval()?
function test() {
eval("var myVariable = 5");
var locals = magic() // TODO What should we do here?
alert(locals["myVariable"]); // returns myVariable
}
Just a note: JavaScript being evaluated comes from a trusted source.