js 语句中那些你不了解的

for语句:
 
for语句的变量不会随着循环的结束而被销毁
for(var i=0;i<5;i++){
console.log("正常输出");
}
console.log(i);
//  2 正常输出
//  5

 

with 语句:

作用是将代码的作用域设置到一个特定的对象中。

with(location){
var qs = search.substring(1);
var hostName=hostname;
var url=href;
console.log(qs);

console.log(hostName);

console.log(url);
}

 

posted @ 2017-07-06 13:04  若栖1017  阅读(93)  评论(0编辑  收藏  举报