aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/javascript/reference/operators/equality/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/ko/web/javascript/reference/operators/equality/index.html')
-rw-r--r--files/ko/web/javascript/reference/operators/equality/index.html123
1 files changed, 123 insertions, 0 deletions
diff --git a/files/ko/web/javascript/reference/operators/equality/index.html b/files/ko/web/javascript/reference/operators/equality/index.html
new file mode 100644
index 0000000000..5ebe238590
--- /dev/null
+++ b/files/ko/web/javascript/reference/operators/equality/index.html
@@ -0,0 +1,123 @@
+---
+title: 동등 연산자(==)
+slug: Web/JavaScript/Reference/Operators/Equality
+translation_of: Web/JavaScript/Reference/Operators/Equality
+---
+<div>{{jsSidebar("Operators")}}</div>
+
+<p>동등 연산자(==)는 두 개의 피연산자가 동일한지 확인하며, Boolean값을 반환합니다. <a href="/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality">일치 연산자</a>(===)와는 다르게 다른 타입의 피연산자들끼리의 비교를 시도합니다. </p>
+
+<div>{{EmbedInteractiveExample("pages/js/expressions-equality.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">x == y
+</pre>
+
+<h2 id="상세_설명">상세 설명</h2>
+
+<p>동등 연산자 (<code>==</code> 와 <code>!=</code>)는 두 피연산자를 비교하기 위해 <a href="http://www.ecma-international.org/ecma-262/5.1/#sec-11.9.3">Abstract Equality Comparison Algorithm</a>를 사용합니다. 다음과 같이 간략히 설명할 수 있습니다:</p>
+
+<ul>
+ <li>두 피연산자가 모두 객체일때, 두 피연산자가 동일한 객체를 참조할때에만 true를 반환합니다.</li>
+ <li>하나의 피연산자가 <code>null</code>이고 다른 하나가 <code>undefined</code>일때, <code>true</code>를 반환합니다.</li>
+ <li>두 피연산자의 타입이 다를 경우, 비교하기 전에 동일한 타입으로 변환하도록 합니다:
+ <ul>
+ <li>숫자와 문자열을 비교할 경우, 문자열을 숫자로 변환하도록 합니다.</li>
+ <li>하나의 피연산자가 <code>Boolean</code>일 경우, Boolean 피연산자가 true일 경우 1로 변환하고, false일 경우, +0으로 변환합니다.</li>
+ <li>하나의 피연산자가 객체이고 다른하나가 숫자나 문자열이면, 객체를  <code>valueOf()</code>나<code>toString()</code>를 사용해 기본 데이터 타입으로 변환하도록 합니다.</li>
+ </ul>
+ </li>
+ <li>두개의 피연산자가 동일한 타입일 경우, 다음과 같이 비교됩니다:
+ <ul>
+ <li><code>String</code>: 두 피연산자가 동일한 문자순서가 동일한 문자열일 경우, <code>true</code>를 반환합니다.</li>
+ <li><code>Number</code>: 두 피연산자가 동일한 값을 가질 경우, <code>true</code>을 반환합니다. +0 과 -0 은 동일한 값으로 취급합니다. 어느 한쪽이 <code>NaN</code>일 경우, <code>false</code>를 반환합니다.</li>
+ <li><code>Boolean</code>: 두 피연산자가 모두 <code>true</code>이거나, 모두 <code>false</code>일 경우, <code>true</code>를 반환합니다. </li>
+ </ul>
+ </li>
+</ul>
+
+<p><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality">일치연산자</a> (<code>===</code>)와의 가장 두드러지는 차이점은 일치 연산자는 타입변환을 시도하지 않는다는 것입니다. 일치 연산자는 다른 타입을 가진 피연산자는 다르다고 판단합니다.</p>
+
+<h2 id="예시">예시</h2>
+
+<h3 id="타입변환_없이_비교">타입변환 없이 비교</h3>
+
+<pre class="brush: js notranslate">1 == 1; // true
+"hello" == "hello"; // true</pre>
+
+<h3 id="타입변환을_이용한_비교">타입변환을 이용한 비교</h3>
+
+<pre class="brush: js notranslate">"1" == 1; // true
+1 == "1"; // true
+0 == false; // true
+0 == null; // false
+0 == undefined; // false
+0 == !!null; // true, look at Logical NOT operator
+0 == !!undefined; // true, look at Logical NOT operator
+null == undefined; // true
+
+const number1 = new Number(3);
+const number2 = new Number(3);
+number1 == 3; // true
+number1 == number2; // false</pre>
+
+<h3 id="객체들_간의_비교">객체들 간의 비교</h3>
+
+<pre class="brush: js notranslate">const object1 = {"key": "value"}
+const object2 = {"key": "value"};
+
+object1 == object2 // false
+object2 == object2 // true</pre>
+
+<h3 id="String과_String_objects의_비교">String과 String objects의 비교</h3>
+
+<p><code>new String()</code> 을 통해 생성된 문자열들은 객체입니다. 이 객체중 하나를 문자열과 비교한다면, <code>String</code> 객체가 문자열로 변환된 후 비교될 것입니다. 그러나 두개의 피연산자 모두 <code>String</code> 객체라면, 객체로써 비교가 이루어지기 때문에 같은 값으로 취급될려면 같은 객체를 참조하고 있어야 합니다:</p>
+
+<pre class="brush: js notranslate">const string1 = "hello";
+const string2 = String("hello");
+const string3 = new String("hello");
+const string4 = new String("hello");
+
+console.log(string1 == string2); // true
+console.log(string1 == string3); // true
+console.log(string2 == string3); // true
+console.log(string3 == string4); // false
+console.log(string4 == string4); // true</pre>
+
+<h3 id="Comparing_Dates_and_strings">Comparing Dates and strings</h3>
+
+<pre class="brush: js notranslate">const d = new Date('December 17, 1995 03:24:00');
+const s = d.toString(); // for example: "Sun Dec 17 1995 03:24:00 GMT-0800 (Pacific Standard Time)"
+console.log(d == s); //true</pre>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-equality-operators', 'Equality operators')}}</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+
+
+<p>{{Compat("javascript.operators.equality")}}</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Inequality">Inequality operator</a></li>
+ <li><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality">Strict equality operator</a></li>
+ <li><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Strict_inequality">Strict inequality operator</a></li>
+</ul>