js中with用法

with语句将代码的作用域设置到一个特定的对象中

严格模式下不允许使用with语句。大量使用with语句会导致性能下降。

with(location) {
  var a1 = search
  var a2 = host
  console.log(a1,a2)
}
console.log(a1,a2)

 

posted @ 2020-05-14 16:22  聿廴  阅读(90)  评论(0)    收藏  举报