Getting references to local variables created during eval() in JavaScript
Posted
by David Parunakian
on Stack Overflow
See other posts from Stack Overflow
or by David Parunakian
Published on 2010-06-16T14:26:28Z
Indexed on
2010/06/16
14:32 UTC
Read the original article
Hit count: 243
JavaScript
|eval
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.
© Stack Overflow or respective owner