with JavaScript · 关键字
已废弃的语句:把对象的属性展开到当前作用域链中,严格模式下禁用。
怎么用
with (对象) { ... }
小例子
'use strict'
with ({}) {}
编译结果
SyntaxError: Strict mode code may not include a with statement
提醒:现代代码不要用它,会造成作用域歧义和性能问题。
官方文档:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/with
在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← JavaScript全部词条