No. JS engines detect of eval in the AST.
It's why you can't rename eval and reference the current scope.
const eval2 = eval;
(() => {
const a = 1;
eval2("a");
})();
// ReferenceError: a is not defined
---The reason JS engines choose to share the closure record among all closures create in the function scope is purely for performance.
function f() {
const a = {};
const b = {};
return [
() => a,
() => b,
];
}
Both functions share the same single closure record, referencing a and b.JavaScript developers have rediscovered this over and over and over again.
* Meteor.js (2013) [1]
* My personal journey (2013) [2]
[1] https://blog.meteor.com/an-interesting-kind-of-javascript-me...
[2] https://stackoverflow.com/questions/19798803/how-javascript-...