❗modify current scope at runtime❗️
🚧 施工中
eval("var a = 'aaa!';");function modifyScope() {
// ⭐️ modify current (function) scope at runtime
eval("var a = 'aaa!';");
// ╰── `a` is in "function scope"❗
console.log(a); // `a` is visible.
}
modifyScope(); // aaa!var scope = { name: "Joy" };
// ⭐️ `with`
// -------------------------------------------------------
// turns an object into a local scope,
// its properties are treated as identifiers in the block:
with (scope) {
console.log(name); // Joy
// ^^^^ // `name` is visible.
}Last updated