4 ms·
I saw a trick where you just do: const eval2 = eval eval2(...) That put’s it back in global scope, even when assigned within a closure with access to a l
by sbr464 8y ago
I saw a trick where you just do:
const eval2 = eval
eval2(...)
That put’s it back in global scope, even when assigned within a closure with access to a local variable. The local variable will be undefined, rather than it’s actual value, even when called next to the regular eval(). Odd, I know.
Here’s a quote:
"any invocation of eval that is not a direct call uses the global environment as its variable environment rather than the caller’s variable environment." ECMAScript 5 standard,