JavaScript中的while循环语句是做什么的?
do...while循环与while循环类似,除了条件检查发生在循环的末尾。这意味着即使条件为假,循环也将至少执行一次。
语法
JavaScript中do-while循环的语法如下,
do{
Statement(s) to be executed;
} while(expression);示例
请尝试以下示例,以了解如何在JavaScript中实现do-while循环,
<html>
<body>
<script>
var count = 0;
document.write("Starting Loop" + "<br />");
do{
document.write("Current Count : " + count + "<br/>");
count++;
}
while(count < 5);
document.write ("循环停止!");
</script>
</body>
</html>