mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-12-15 23:37:25 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<p><strong>逗号操作符 </strong> 对它的每个操作数求值(从左到右),并返回最后一个操作数的值。</p>
|
||||
<p><iframe class="interactive interactive-js" frameborder="0" height="250" src="https://interactive-examples.mdn.mozilla.net/pages/js/expressions-commaoperators.html" width="100%"></iframe></p>
|
||||
<h2 id="语法">语法</h2>
|
||||
<pre class="syntaxbox"><em>expr1</em>, <em>expr2, expr3...</em></pre>
|
||||
<pre><code class="language-javascript"><em>expr1</em>, <em>expr2, expr3...</em></code></pre>
|
||||
<h2 id="参数">参数</h2>
|
||||
<dl>
|
||||
<dt><code>expr1</code>, <code>expr2, expr3...</code></dt>
|
||||
@@ -15,15 +15,15 @@
|
||||
<p>当你想要在期望一个表达式的位置包含多个表达式时,可以使用逗号操作符。这个操作符最常用的一种情况是:<code>for</code> 循环中提供多个参数。</p>
|
||||
<h2 id="示例">示例</h2>
|
||||
<p>假设 <code>a</code> 是一个二维数组,每一维度包含10个元素,则下面的代码使用逗号操作符一次递增/递减两个变量。需要注意的是,<code>var</code> 语句中的逗号<em><strong>不是</strong></em>逗号操作符,因为它不是存在于一个表达式中。尽管从实际效果来看,那个逗号同逗号运算符的表现很相似。但确切地说,它是 <code style="font-style: normal;">var</code> 语句中的一个特殊符号,用于把多个变量声明结合成一个。下面的代码打印一个二维数组中斜线方向的元素:</p>
|
||||
<pre class="brush:js;highlight:[1]">for (var i = 0, j = 9; i <= 9; i++, j--)
|
||||
document.writeln("a[" + i + "][" + j + "] = " + a[i][j]);</pre>
|
||||
<pre><code class="language-js;highlight:[1]">for (var i = 0, j = 9; i <= 9; i++, j--)
|
||||
document.writeln("a[" + i + "][" + j + "] = " + a[i][j]);</code></pre>
|
||||
<h3 id="处理后返回">处理后返回</h3>
|
||||
<p>另一个使用逗号操作符的例子是在返回值前处理一些操作。如同下面的代码,只有最后一个表达式被返回,其他的都只是被求值。</p>
|
||||
<pre>function myFunc () {
|
||||
var x = 0;
|
||||
|
||||
return (x += 1, x); // the same of return ++x;
|
||||
}</pre>
|
||||
}</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
Reference in New Issue
Block a user