for (变量=开始值;变量<=结束值;变量=变量+步进值)
{
    需执行的代码  
}
  <html><body><script type="text/javascript">var i=0for (i=0;i<=10;i++){document.write("The number

is " + i)document.write("<br />")}</script></body></html>

结果:

The number is 0
The number is 1
The number is 2
The number is 3
The number is 4
The number is 5
The number is 6
The number is 7
The number is 8
The number is 9
 The number is 10

while (变量<=结束值)
{
    需执行的代码
}
 <html><body><script type="text/javascript">var xvar mycars = new Array()mycars[0]

= "Saab"mycars[1] = "Volvo"mycars[2] = "BMW"for (x in mycars){document.write(mycars[x] + "<br />")}</script></body></html>

无觅相关文章插件