--- title: デクリメント (--) slug: Web/JavaScript/Reference/Operators/Decrement tags: - Decrement - JavaScript - Language feature - Operator translation_of: Web/JavaScript/Reference/Operators/Decrement --- <div>{{jsSidebar("Operators")}}</div> <p>デクリメント演算子 (<code>--</code>) は、オペランドをデクリメント (1を減算) して値を返します。</p> <div>{{EmbedInteractiveExample("pages/js/expressions-decrement.html")}}</div> <div></div> <h2 id="構文">構文</h2> <pre class="syntaxbox notranslate"><strong>Operator:</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', 'Decrement operator')}}</td> </tr> </tbody> </table> <h2 id="ブラウザーの互換性">ブラウザーの互換性</h2> <p>{{Compat("javascript.operators.decrement")}}</p> <h2 id="関連項目">関連項目</h2> <ul> <li><a href="https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Addition">加算演算子</a></li> <li><a href="https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Subtraction">減算演算子</a></li> <li><a href="https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Multiplication">乗算演算子</a></li> <li><a href="https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Division">除算演算子</a></li> <li><a href="https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Remainder">剰余演算子</a></li> <li><a href="https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Exponentiation">べき乗演算子</a></li> <li><a href="https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Increment">インクリメント演算子</a></li> <li><a href="https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Unary_negation">単項マイナス演算子</a></li> <li><a href="https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Unary_plus">単項プラス演算子</a></li> </ul>