mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2026-02-28 10:03:04 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
<div></div>
|
||||
<p><strong>while 语句</strong>可以在某个条件表达式为真的前提下,循环执行指定的一段代码,直到那个表达式不为真时结束循环。</p>
|
||||
<h2 id="Syntax" name="Syntax">语法</h2>
|
||||
<pre class="syntaxbox">while (<em>condition</em>) {
|
||||
<pre><code class="language-javascript">while (<em>condition</em>) {
|
||||
<em>statement</em>
|
||||
}</pre>
|
||||
}</code></pre>
|
||||
<dl>
|
||||
<dt><code>condition</code></dt>
|
||||
<dd>条件表达式,在每次循环前被求值。如果求值为真,<code>statement</code>就会被执行。如果求值为假,则跳出<code>while</code>循环执行后面的语句。</dd>
|
||||
@@ -14,13 +14,13 @@
|
||||
</dl>
|
||||
<h2 id="Examples" name="Examples">示例</h2>
|
||||
<p>下面的<code>while</code>循环会一直循环若干次直到 <code>n</code> 等于 <code>3</code>。</p>
|
||||
<pre class="brush:js">var n = 0;
|
||||
<pre><code class="language-js">var n = 0;
|
||||
var x = 0;
|
||||
|
||||
while (n < 3) {
|
||||
n++;
|
||||
x += n;
|
||||
}</pre>
|
||||
}</code></pre>
|
||||
<p>在每次循环中,<code>n</code> 都会自增 <code>1</code>,然后再把 <code>n</code> 加到 <code>x</code> 上。因此,在每轮循环结束后,<code>x</code> 和 <code>n</code> 的值分别是:</p>
|
||||
<ul>
|
||||
<li>第一轮后:<code>n</code> = 1,<code>x</code> = 1</li>
|
||||
|
||||
Reference in New Issue
Block a user