aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/javascript/reference/operators/logical_and_assignment
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/javascript/reference/operators/logical_and_assignment
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/ja/web/javascript/reference/operators/logical_and_assignment')
-rw-r--r--files/ja/web/javascript/reference/operators/logical_and_assignment/index.html89
1 files changed, 89 insertions, 0 deletions
diff --git a/files/ja/web/javascript/reference/operators/logical_and_assignment/index.html b/files/ja/web/javascript/reference/operators/logical_and_assignment/index.html
new file mode 100644
index 0000000000..1e74fc6b2d
--- /dev/null
+++ b/files/ja/web/javascript/reference/operators/logical_and_assignment/index.html
@@ -0,0 +1,89 @@
+---
+title: 論理積代入 (&&=)
+slug: Web/JavaScript/Reference/Operators/Logical_AND_assignment
+tags:
+ - JavaScript
+ - Language feature
+ - Logical assignment
+ - Operator
+ - Reference
+translation_of: Web/JavaScript/Reference/Operators/Logical_AND_assignment
+---
+<div>{{jsSidebar("Operators")}}</div>
+
+<p>論理積代入 (<code>x &amp;&amp;= y</code>) 演算子は、<code>x</code> が {{Glossary("truthy")}} である場合にのみ代入します。</p>
+
+<div>{{EmbedInteractiveExample("pages/js/expressions-logical-and-assignment.html")}}</div>
+
+<div class="hidden">The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> and send us a pull request.</div>
+
+<h2 id="構文">構文</h2>
+
+<pre class="syntaxbox notranslate"><em>expr1</em> &amp;&amp;= <em>expr2</em>
+</pre>
+
+<h2 id="説明">説明</h2>
+
+<h3 id="短絡評価(ショートサーキット)">短絡評価(ショートサーキット)</h3>
+
+<p><a href="/docs/Web/JavaScript/Reference/Operators/Logical_AND">論理積演算子</a>は左から右に評価され、次のルールを使って短絡評価の可能性があるかどうかテストされます。</p>
+
+<p><code>(偽値の式) &amp;&amp; expr</code> は、偽値の式が短絡評価されます。</p>
+
+<p>短絡評価とは、上記の <code><em>expr</em></code> 部分が<strong>評価されない</strong>ことを意味します。したがって、評価された場合の副作用は発生しません。(例えば、<code><em>expr</em></code> が関数呼び出しである場合、呼び出しは行われません。)</p>
+
+<p>論理積代入も短絡評価されます。これは、<code>x &amp;&amp;= y</code> が以下と等価であることを意味します。</p>
+
+<pre class="brush: js notranslate">x &amp;&amp; (x = y);</pre>
+
+<p>そして、常に代入が行われる以下と等価ではありません。</p>
+
+<pre class="brush: js notranslate example-bad">x = x &amp;&amp; y;
+</pre>
+
+<h2 id="例">例</h2>
+
+<h3 id="論理積代入演算子の使用">論理積代入演算子の使用</h3>
+
+<pre class="brush: js notranslate">let x = 0;
+let y = 1;
+
+x &amp;&amp;= 0; // 0
+x &amp;&amp;= 1; // 0
+y &amp;&amp;= 1; // 1
+y &amp;&amp;= 0; // 0
+</pre>
+
+<h2 id="仕様">仕様</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">仕様書</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ </tr>
+ <tr>
+ <td>{{SpecName('Logical Assignment', '#sec-assignment-operators', 'Assignment operators')}}</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="ブラウザの互換性">ブラウザの互換性</h2>
+
+
+
+<p>{{Compat("javascript.operators.logical_and_assignment")}}</p>
+
+<h2 id="関連情報">関連情報</h2>
+
+<ul>
+ <li><a href="/ja/docs/Web/JavaScript/Reference/Operators/Logical_AND">論理積 (&amp;&amp;)</a></li>
+ <li><a href="/ja/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator">Null合体 (<code>??</code>)</a></li>
+ <li><a href="/ja/docs/Web/JavaScript/Reference/Operators/Bitwise_AND_assignment">ビット論理積代入 (<code>&amp;=</code>)</a></li>
+ <li>{{jsxref("Boolean")}}</li>
+ <li>{{Glossary("Truthy")}}</li>
+ <li>{{Glossary("Falsy")}}</li>
+</ul>