aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/operators/decrement/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/javascript/reference/operators/decrement/index.html')
-rw-r--r--files/zh-cn/web/javascript/reference/operators/decrement/index.html86
1 files changed, 86 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/operators/decrement/index.html b/files/zh-cn/web/javascript/reference/operators/decrement/index.html
new file mode 100644
index 0000000000..aca67c15f9
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/operators/decrement/index.html
@@ -0,0 +1,86 @@
+---
+title: 自减 (--)
+slug: Web/JavaScript/Reference/Operators/Decrement
+tags:
+ - JavaScript
+ - 自减
+ - 语法特性
+ - 运算符
+translation_of: Web/JavaScript/Reference/Operators/Decrement
+original_slug: Web/JavaScript/Reference/Operators/自减
+---
+<div>{{jsSidebar("Operators")}}</div>
+
+<p> 自减运算符(<code>--</code>) 将它的操作数减一,然后返回操作数.</p>
+
+<div>{{EmbedInteractiveExample("pages/js/expressions-decrement.html")}}</div>
+
+<div></div>
+
+
+
+<h2 id="语法"><br>
+ 语法</h2>
+
+<pre class="syntaxbox notranslate"><strong>操作符:</strong> <var>x</var>-- or --<var>x</var>
+</pre>
+
+<h2 id="语法细节">语法细节</h2>
+
+<p>如果使用后缀式,即将操作符放在操作数的后面 (如,<code><var>x</var>--</code>),运算会减一,然后返回减一之前的值。</p>
+
+<p>如果使用前缀式,即将操作符放在操作数的前面 (如,<code>--<var>x</var></code>),运算会减一,然后返回减一之后的值。</p>
+
+<h2 id="示例">示例</h2>
+
+<h3 id="后缀式">后缀式</h3>
+
+<pre class="brush: js notranslate">let x = 3;
+y = x--;
+
+// y = 3
+// x = 2
+</pre>
+
+<h3 id="前缀式">前缀式</h3>
+
+<pre class="brush: js notranslate">let a = 2;
+b = --a;
+
+// a = 1
+// b = 1
+</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">规范</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-postfix-decrement-operator', '自减运算符')}}</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性"><br>
+ 浏览器兼容性</h2>
+
+
+
+<p>{{Compat("javascript.operators.decrement")}}</p>
+
+<h2 id="相关链接">相关链接</h2>
+
+<ul>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Addition">Addition operator</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Subtraction">Subtraction operator</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Division">Division operator</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Multiplication">Multiplication operator</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Remainder">Remainder operator</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Exponentiation">Exponentiation operator</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Increment">Increment operator</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Unary_negation">Unary negation operator</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Unary_plus">Unary plus operator</a></li>
+</ul>