js 循环
Posted justSmile2
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js 循环相关的知识,希望对你有一定的参考价值。
1. for 循环
for (var i=0; i<5; i++) { console.log(‘hello‘); }
2. for in 循环
var person={fname:"John",lname:"Doe",age:25};
for (x in
person)
{
txt=txt + person[x];
}
3. while 循环
while (i<5) { x=x + "The number is " + i + "<br>"; i++; }
cars=["BMW","Volvo","Saab","Ford"]; var i=0; for (;cars[i];) { document.write(cars[i] + "<br>"); i++; }
4. do/while 循环
do { x=x + "The number is " + i + "<br>"; i++; } while (i<5);
1.for循环
1.for循环
1.for循环
1.for循环
以上是关于js 循环的主要内容,如果未能解决你的问题,请参考以下文章