Within JS It also has a while loop and a Do While loop, and let's look at the while loop action and the example tutorial.
The number of times specified to execute the same code block in JavaScript or the specified condition is true.
Example
While
How to write a while loop. Use the while loop to run the same code block, and the specified condition is true.
<script type= "Text/javascript" >
i=0;
while (i<=5)
{
document.write ("The number is" + i);
document.write ("<br/>");
i++;
}
</script>
Do While loop
How to write this ... while loop. Use this ... while loop to run the same code block, and the specified condition is true. This cycle will always be executed at least once, even if the condition is false, since the statement is the test before the condition is enforced.
<script type= "Text/javascript" >
i = 0;
Todo
{
document.write ("The number is" + i);
document.write ("<br/>");
i++;
}
while (I <= 5)
</script>
In the While loop
The while loop is used when you want to loop execution and continue execution, while the specified condition is true.
while (Var<=endvalue)
{code to IS
executed
}
Reprint Please note: http://www.111cn.net/wy/yw.html