JavaScript/while:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
Kangkk​(留言 | 贡献)
小 文字替换 -“{{leftrightflex|”替换为“{{Double-columns|”
标签:ReplaceText 移动版编辑 移动版网页编辑
 
(未显示同一用户的2个中间版本)
第2行: 第2行:
== 结束 ==
== 结束 ==
=== break ===
=== break ===
{{leftrightflex|<syntaxhighlight lang="javascript">
{{Double-columns|<syntaxhighlight lang="javascript">
let i = 0;
let i = 0;
while (i < 5) {
while (i < 5) {
第24行: 第24行:
== 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(表达式);