This commit is contained in:
fofolee
2019-04-21 11:50:48 +08:00
parent 359d29ee0b
commit 38dcd51d8a
6901 changed files with 258583 additions and 2326828 deletions

View File

@@ -1,35 +1,35 @@
<article id="wikiArticle">
<div></div>
<h2 id="Message">Message</h2>
<pre><code class="language-javascript">ReferenceError: invalid assignment left-hand side
</code></pre>
<h2 id="Error_type">Error type</h2>
<p><a href="Reference/Global_Objects/ReferenceError" title="ReferenceError引用错误 对象代表当一个不存在的变量被引用时发生的错误。"><code>ReferenceError</code></a>.</p>
<h2 id="What_went_wrong">What went wrong?</h2>
<p>有时会出现不可预料的赋值情况。这可能是因为<a href="Reference/Operators/Assignment_Operators">赋值运算符</a><a href="Reference/Operators/Comparison_Operators">比较运算符</a>不匹配的缘故。正确的是,使用“=”号将值赋给一个变量,使用“==”或者“===”来比较一个值。</p>
<h2 id="Examples">Examples</h2>
<pre><code class="language-js example-bad">if (Math.PI = 3 || Math.PI = 4) {
console.log('no way!');
}
// ReferenceError: invalid assignment left-hand side
var str = 'Hello, '
+= 'is it me '
+= 'you\'re looking for?';
// ReferenceError: invalid assignment left-hand side
</code></pre>
<p><code>if</code> 语句中,你要使用比较运算符("=="),而在字符串连接中,使用加号运算符("+")。</p>
<pre><code class="language-js example-good">if (Math.PI == 3 || Math.PI == 4) {
console.log('no way!');
}
var str = 'Hello, '
+ 'from the '
+ 'other side!';
</code></pre>
<h2 id="See_also">See also</h2>
<ul>
<li><a href="Reference/Operators/Assignment_Operators">赋值运算符</a></li>
<li><a href="Reference/Operators/Comparison_Operators">比较运算符</a></li>
</ul>
<article id="wikiArticle">
<div></div>
<h2 id="Message">Message</h2>
<pre><code class="language-javascript">ReferenceError: invalid assignment left-hand side
</code></pre>
<h2 id="Error_type">Error type</h2>
<p><a href="Reference/Global_Objects/ReferenceError" title="ReferenceError引用错误 对象代表当一个不存在的变量被引用时发生的错误。"><code>ReferenceError</code></a>.</p>
<h2 id="What_went_wrong">What went wrong?</h2>
<p>有时会出现不可预料的赋值情况。这可能是因为<a href="Reference/Operators/Assignment_Operators">赋值运算符</a><a href="Reference/Operators/Comparison_Operators">比较运算符</a>不匹配的缘故。正确的是,使用“=”号将值赋给一个变量,使用“==”或者“===”来比较一个值。</p>
<h2 id="Examples">Examples</h2>
<pre><code class="language-js example-bad">if (Math.PI = 3 || Math.PI = 4) {
console.log('no way!');
}
// ReferenceError: invalid assignment left-hand side
var str = 'Hello, '
+= 'is it me '
+= 'you\'re looking for?';
// ReferenceError: invalid assignment left-hand side
</code></pre>
<p><code>if</code> 语句中,你要使用比较运算符("=="),而在字符串连接中,使用加号运算符("+")。</p>
<pre><code class="language-js example-good">if (Math.PI == 3 || Math.PI == 4) {
console.log('no way!');
}
var str = 'Hello, '
+ 'from the '
+ 'other side!';
</code></pre>
<h2 id="See_also">See also</h2>
<ul>
<li><a href="Reference/Operators/Assignment_Operators">赋值运算符</a></li>
<li><a href="Reference/Operators/Comparison_Operators">比较运算符</a></li>
</ul>
</article>