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 入住酒店文案祝福语简短