for循环的代码循环
解释:下面的例子定义了一个循环程序,这个程序中 i 的起始值为 0。每执行一次循环,i 的值就会累加一次 1,循环会一直运行下去,直到 i 等于 10 为止。
注释:步进值可以为负。如果步进值为负,需要调整 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 0The number is 1The number is 2The number is 3The number is 4The number is 5The number is 6The number is 7The number is 8The number is 9The number is 10
The number is 0The number is 1The number is 2The number is 3The number is 4The number is 5The number is 6The number is 7The number is 8The number is 9The number is 10