with语句的作用是将代码的作用域设置到一个特定的对象中具体用法:
with(expression) statement;
let qs = location.search.substring(1);
let hostName = location.hostname;
let url = location.href;
使用with语句后:
with(location){
let qs = sarch.subsring(1);
let hostName = hostname;
let url = href;
}