News for hackers. Stuff that matters.
Re:Is eval evil? Just-in-time compiling by robocat on Monday November 19, 2018 @03:36PM (#18489557)
Generally I always use Function() instead of eval, because Function doesn't capture the current scope (and also it won't interfere with JIT optimisation, and avoids possible memory bloat of variables in closure if you keep references to the functions).
Re:Is eval evil? Just-in-time compiling by sbr464 on Tuesday November 20, 2018 @07:32AM (#18493347)
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,