Home >Web Front-end >Front-end Q&A >What is the meaning of while in javascript
In JavaScript, while means "when...the condition is met". It is a loop statement with the syntax of "while (condition) {code block to be executed}"; when the specified condition is true , the while loop will continue to execute the code block in "{}".
The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.
What does while mean in JavaScript
In JavaScript, the meaning of while is "when...", "when... is satisfied. ..conditions”. Is a loop statement, the while loop will continue to loop through the code block as long as the specified condition is true.
The syntax is as follows:
while (条件) {要执行的代码块}
The example is as follows:
<html> <body> <h2>JavaScript while</h2> <p id="demo"></p> <script> var text = ""; var i = 0; while (i < 10) { text += "<br>数字是 " + i; i++; } document.getElementById("demo").innerHTML = text; </script> </body> </html>
Output result:
[Recommended learning :javascript advanced tutorial】
The above is the detailed content of What is the meaning of while in javascript. For more information, please follow other related articles on the PHP Chinese website!