blob: 7a7acf3ca2d34b51ff03c988df0efa1091afa4f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
---
title: 'ReferenceError: invalid assignment left-hand side'
slug: Web/JavaScript/Reference/Errors/Invalid_assignment_left-hand_side
translation_of: Web/JavaScript/Reference/Errors/Invalid_assignment_left-hand_side
---
<div>{{jsSidebar("Errors")}}</div>
<h2 id="메시지">메시지</h2>
<pre class="syntaxbox">ReferenceError: invalid assignment left-hand side
</pre>
<h2 id="에러_타입">에러 타입</h2>
<p>{{jsxref("ReferenceError")}}.</p>
<h2 id="무엇이_잘못되었을까">무엇이 잘못되었을까?</h2>
<p>예상치 못한 할당이 일어났습니다. 이것은 할당 연산자(<a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators">assignment operator</a>)와 비교 연산자(<a href="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators">comparison operator</a>) 간의 불일치로 인한 것일 겁니다. 예를 들면, "<code>=</code>" 부호는 값을 변수에 할당합니다. "<code>==</code>" 나 "<code>===</code>"는 값을 비교하는 연산을 합니다.</p>
<h2 id="예">예</h2>
<pre class="brush: 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
</pre>
<p><code>if </code>구문에서, 비교 연산자 ("==")로 비교하려 할 때, 문자열의 연속적인 결합의 경우에는, 플러스("+") 연산자가 필요합니다.</p>
<pre class="brush: js example-good">if (Math.PI == 3 || Math.PI == 4) {
console.log('no way!');
}
var str = 'Hello, '
+ 'from the '
+ 'other side!';
</pre>
<h2 id="참조">참조</h2>
<ul>
<li><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators">Assignment operators</a></li>
<li><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators">Comparison operators</a></li>
</ul>
|