js 语句

Posted 若栖1017

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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);
}

 

以上是关于js 语句的主要内容,如果未能解决你的问题,请参考以下文章