A
Adam C.
Mozilla.org suggests using the with statement to control bindings:
var f = 2;
with({f: 3}){
eval("f"); // evaluates to 3
}
But that doesn't work for binding "this".
setTimeout (with a string to be evaluated) will evaluate "this" as the
window.
eval.call(someObj, "this")
returns an error in Firefox; in IE is seems to just bind "this" to the
window.
Is there a way to completely control the bindings, including this, of
the code to be evaluated?
var f = 2;
with({f: 3}){
eval("f"); // evaluates to 3
}
But that doesn't work for binding "this".
setTimeout (with a string to be evaluated) will evaluate "this" as the
window.
eval.call(someObj, "this")
returns an error in Firefox; in IE is seems to just bind "this" to the
window.
Is there a way to completely control the bindings, including this, of
the code to be evaluated?