mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-12-18 08:54:32 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -4,26 +4,26 @@
|
||||
</div>
|
||||
<p><strong>空语句</strong>用来表明没有语句,尽管 JavaScript 语法希望有语句。</p>
|
||||
<h2 id="语法">语法</h2>
|
||||
<pre class="syntaxbox">;
|
||||
</pre>
|
||||
<pre><code class="language-javascript">;
|
||||
</code></pre>
|
||||
<h2 id="描述">描述</h2>
|
||||
<p><span class="short_text" id="result_box" lang="zh-CN"><span>空语句是一个分号(;),表示不会执行任何语句,即使 JavaScript 语法需要一个语句。</span></span> 相反,当你需要多行语句,但 JavaScript 只允许一个时,可以使用<a href="Reference/Statements/block">语句块</a>;语句块可以将多条语句合并为一个。</p>
|
||||
<h2 id="示例">示例</h2>
|
||||
<p>空<span class="short_text" lang="zh-CN"><span>语句有时与循环语句一起使用。以下示例使用空循环体:</span></span></p>
|
||||
<pre class="brush: js">var arr = [1, 2, 3];
|
||||
<pre><code class="language-javascript">var arr = [1, 2, 3];
|
||||
|
||||
// Assign all array values to 0
|
||||
for (let i = 0; i < arr.length; arr[i++] = 0) /* empty statement */ ;
|
||||
|
||||
console.log(arr)
|
||||
// [0, 0, 0]
|
||||
</pre>
|
||||
</code></pre>
|
||||
<p><strong>提示:</strong>在使用空语句的情况下专门写上注释是个不错的主意,因为不是很容易区分空语句和普通的分号。下面的示例可能不是故意加上分号的:</p>
|
||||
<pre class="brush: js">if (condition); // Caution, this "if" does nothing!
|
||||
<pre><code class="language-javascript">if (condition); // Caution, this "if" does nothing!
|
||||
killTheUniverse() // So this gets always executed!!!
|
||||
</pre>
|
||||
</code></pre>
|
||||
<p>另一个例子:<a href="/en-US/docs/Web/JavaScript/Reference/Statements/if...else"><code>if...else</code></a> 语句不带花括号(<code>{}</code>)。如果<code>three</code>为<code>true</code>, 不会发生任何事,<code>four</code>不会执行,同时<code>else</code>从句中的<code>launchRocket()</code>函数也不会执行。</p>
|
||||
<pre class="brush: js">if (one)
|
||||
<pre><code class="language-javascript">if (one)
|
||||
doOne();
|
||||
else if (two)
|
||||
doTwo();
|
||||
@@ -32,7 +32,7 @@ else if (three)
|
||||
else if (four)
|
||||
doFour();
|
||||
else
|
||||
launchRocket();</pre>
|
||||
launchRocket();</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
Reference in New Issue
Block a user