JavaScript/while:修订间差异
来自康健生活
小 文字替换 -“{{leftrightflex|”替换为“{{Double-columns|” 标签:ReplaceText 移动版编辑 移动版网页编辑 |
|||
| (未显示同一用户的4个中间版本) | |||
| 第1行: | 第1行: | ||
== 引言 == | == 引言 == | ||
== 结束 == | == 结束 == | ||
=== break === | |||
{{Double-columns|<syntaxhighlight lang="javascript"> | |||
let i = 0; | |||
while (i < 5) { | |||
console.log('the i is ', i); | |||
if(i===2) break; | |||
i++; | |||
}</syntaxhighlight>|{{consoleout|<pre> | |||
the i is 0 | |||
the i is 1 | |||
the i is 2 | |||
</pre>}}}} | |||
== 死循环 == | == 死循环 == | ||
== while == | == while == | ||
<blockquote><pre> | <blockquote><pre> | ||
while(表达式) {循环体};</pre></blockquote> | while(表达式) { | ||
循环体 | |||
};</pre></blockquote> | |||
== do while == | == do while == | ||
<blockquote><pre> | <blockquote><pre> | ||
do{} while(表达式);</pre></blockquote> | do { | ||
// TODO | |||
} | |||
while(表达式);</pre></blockquote> | |||
2026年11月26日 (四) 07:13的最新版本
引言
结束
break
let i = 0;
while (i < 5) {
console.log('the i is ', i);
if(i===2) break;
i++;
}
the i is 0 the i is 1 the i is 2
死循环
while
while(表达式) {
循环体
};
do while
do {
// TODO
}
while(表达式);No categories