What is the meaning of while in javascript

WBOY
Release: 2021-12-07 14:00:02
Original
2200 people have browsed it

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 "{}".

What is the meaning of while in javascript

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 (条件) {要执行的代码块}
Copy after login

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>
Copy after login

Output result:

What is the meaning of while in javascript

[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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!