【发布时间】:2020-02-10 02:18:59
【问题描述】:
在使用 JavaScript 的 with 语句时,名称无效的变量会去哪里?
var o = {"@#$%":1,"test":2}
with(o){
console.log(test)
// Can't do this:
//console.log(@#$%)
// Was it not imported, or is it just inaccessible?
}
您也可以在 JavaScript 引擎中引用代码吗?
【问题讨论】:
-
如果没有
with语句,无效变量会怎样?你也不能写o.@#$%。 -
@Scaramouche 我知道。
标签: javascript scope internals scope-chain