什么是JavaScript中的while循环语句?
JavaScript中最基本的循环是while循环。while循环的目的是在表达式为真时重复执行语句或代码块。一旦表达式变为假,则循环终止。
语法
JavaScript中while循环的语法如下-
while (expression){
Statement(s) to be executed if expression is true
}示例
您可以尝试运行以下示例以实现while循环
<html>
<body>
<script>
var count = 0;
document.write("Starting Loop ");
while(count < 10){
document.write("Current Count : " + count + "<br/>");
count++;
}
document.write("循环停止!");
</script>
</body>
</html>热门推荐
10 读书祝福语女生短句简短
11 感谢同事新婚祝福语简短
12 感谢教官文案祝福语简短
13 员工聚会蛋糕祝福语简短
14 元宵发客户祝福语简短
15 给团队信心祝福语简短
16 医美的祝福语大全简短
17 异国姻缘的祝福语简短
18 兄妹拍照祝福语简短的话