JavaScript ::循环
在“为”循环是循环的最紧凑的形式。它包括以下三个重要部分-
该 环路初始化 我们初始化我们的初始值计数器。初始化语句在循环开始之前执行。
该 测试的语句 ,如果给定的条件是真还是假,这将考验。如果条件为真,则将执行循环内给出的代码,否则控件将退出循环。
您可以在其中增加或减少计数器的 迭代语句。
您可以将所有三个部分放在由分号分隔的一行中。
流程图
JavaScript中for循环的流程图 如下-
语法
for 循环的语法 是JavaScript如下-
for (initialization; test condition; iteration statement) {
Statement(s) to be executed if test condition is true
}例子
请尝试以下示例,以了解 for 循环在JavaScript中的工作方式。
Set the variable to different value and then try...
输出
Starting Loop Current Count : 0 Current Count : 1 Current Count : 2 Current Count : 3 Current Count : 4 Current Count : 5 Current Count : 6 Current Count : 7 Current Count : 8 Current Count : 9 Loop stopped! Set the variable to different value and then try...
热门推荐
10 祝孙辈生日祝福语简短
11 恋人跨年祝福语大全简短
12 考大学敬酒简短祝福语
13 开工投产大吉祝福语 简短
14 偶然结婚祝福语朋友简短
15 感谢学长学姐祝福语简短
16 戏精的祝福语简短
17 我要结婚祝福语简短
18 婚前女儿生日祝福语简短