diff options
Diffstat (limited to 'files/zh-cn/web/javascript/reference/operators/logical_and/index.html')
-rw-r--r-- | files/zh-cn/web/javascript/reference/operators/logical_and/index.html | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/files/zh-cn/web/javascript/reference/operators/logical_and/index.html b/files/zh-cn/web/javascript/reference/operators/logical_and/index.html index 78c4eee070..e418a76518 100644 --- a/files/zh-cn/web/javascript/reference/operators/logical_and/index.html +++ b/files/zh-cn/web/javascript/reference/operators/logical_and/index.html @@ -14,7 +14,7 @@ original_slug: Web/JavaScript/Reference/Operators/逻辑和 <h2 id="Syntax">Syntax</h2> -<pre class="syntaxbox notranslate"><em>expr1</em> && <em>expr2</em> +<pre class="syntaxbox"><em>expr1</em> && <em>expr2</em> </pre> <h2 id="Description">Description</h2> @@ -43,7 +43,7 @@ original_slug: Web/JavaScript/Reference/Operators/逻辑和 <p>Short circuit means that the <code><em>expr</em></code> part above is <strong>not evaluated</strong>, hence any side effects of doing so do not take effect (e.g., if <code><em>expr</em></code> is a function call, the calling never takes place). This happens because the value of the operator is already determined after the evaluation of the first operand. See example:</p> -<pre class="brush: js notranslate">function A(){ console.log('called A'); return false; } +<pre class="brush: js">function A(){ console.log('called A'); return false; } function B(){ console.log('called B'); return true; } console.log( A() && B() ); @@ -55,7 +55,7 @@ console.log( A() && B() ); <p>The following expressions might seem equivalent, but they are not, because the <code>&&</code> operator is executed before the <code>||</code> operator (see <a href="/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence">operator precedence</a>).</p> -<pre class="brush: js notranslate">true || false && false // returns true, because && is executed first +<pre class="brush: js">true || false && false // returns true, because && is executed first (true || false) && false // returns false, because operator precedence cannot apply</pre> <h2 id="Examples">Examples</h2> @@ -64,7 +64,7 @@ console.log( A() && B() ); <p>The following code shows examples of the <code>&&</code> (logical AND) operator.</p> -<pre class="brush: js notranslate">a1 = true && true // t && t returns true +<pre class="brush: js">a1 = true && true // t && t returns true a2 = true && false // t && f returns false a3 = false && true // f && t returns false a4 = false && (3 == 4) // f && f returns false @@ -80,21 +80,21 @@ a9 = false && '' // f && f returns false</pre> <p>The following operation involving <strong>booleans</strong>:</p> -<pre class="brush: js notranslate">bCondition1 && bCondition2</pre> +<pre class="brush: js">bCondition1 && bCondition2</pre> <p>is always equal to:</p> -<pre class="brush: js notranslate">!(!bCondition1 || !bCondition2)</pre> +<pre class="brush: js">!(!bCondition1 || !bCondition2)</pre> <h4 id="Converting_OR_to_AND">Converting OR to AND</h4> <p>The following operation involving <strong>booleans</strong>:</p> -<pre class="brush: js notranslate">bCondition1 || bCondition2</pre> +<pre class="brush: js">bCondition1 || bCondition2</pre> <p>is always equal to:</p> -<pre class="brush: js notranslate">!(!bCondition1 && !bCondition2)</pre> +<pre class="brush: js">!(!bCondition1 && !bCondition2)</pre> <h3 id="Removing_nested_parentheses">Removing nested parentheses</h3> @@ -102,11 +102,11 @@ a9 = false && '' // f && f returns false</pre> <p>The following composite operation involving <strong>booleans</strong>:</p> -<pre class="brush: js notranslate">bCondition1 || (bCondition2 && bCondition3)</pre> +<pre class="brush: js">bCondition1 || (bCondition2 && bCondition3)</pre> <p>is always equal to:</p> -<pre class="brush: js notranslate">bCondition1 || bCondition2 && bCondition3</pre> +<pre class="brush: js">bCondition1 || bCondition2 && bCondition3</pre> <h2 id="Specifications">Specifications</h2> |