Please consider the two following snippets of code:
(function f() {
var x;
try {
eval("x");
console.log('No error!');
}
catch (e) {
console.log('Error!');
}
}(eval))
and
(function f(eval) {
var x;
try {
eval("x");
console.log('No error!');
}
catch (e) {
console.log('Error!');
}
}(eval))
The first prints No error!, the second prints Error!. Is there a way to access “local eval” inside a function scope for which eval is one of the arguments?
Global functions are part of the
windowobject. Callwindow.eval()instead.