🛡️eval has its own scope in strict mode
🚧 施工中
Last updated
Was this helpful?
🚧 施工中
Last updated
Was this helpful?
Was this helpful?
JS ⟩ concepts ⟩ strict mode ⟩ eval has its own scope in strict mode
in strict mode, script in eval has its own scope.
replit:modify scope at runtime
function evalCannotModifyScopeInStrictMode() {
'use strict'; // ⭐️ strict mode
// ---------------------------------------------------------------
// ⭐️ in strict mode, `eval` doesn't introduce new variables into
// the surrounding scope, they're local to the script itself.
eval("var b = 'bbb!';");