Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015년 7월.
동등 연산자(==)는 두 개의 피연산자가 동일한지 확인하며, 불리언 결과를 반환합니다. 일치 연산자와는 다르게 다른 타입의 피연산자들끼리의 비교를 시도합니다.
동등 연산자 (== 와 !=)는 두 피연산자를 비교하기 위해 느슨한 같음을 사용합니다. 다음과 같이 간략히 설명할 수 있습니다.
동등 연산자는 대칭적입니다. A와 B가 어떤 값을 가져도 A == B는 B == A와 항상 동일한 의미입니다(타입 변환의 적용 순서를 제외하고).
일치 연산자 (===)와의 가장 두드러지는 차이점은 일치 연산자는 타입 변환을 시도하지 않는다는 것입니다. 일치 연산자는 다른 타입을 가진 피연산자는 다르다고 판단합니다. 일치 연산자는 기본적으로 1단계만 수행하고 다른 모든 경우에 false를 반환합니다.
위 알고리즘에는 "고의적 위반"이 있습니다. 한 피연산자가 document.all인 경우, undefined처럼 처리됩니다. 이는 document.all == null은 true지만, document.all === undefined && document.all === null이 false라는 것을 의미합니다.
new String() 을 통해 생성된 문자열들은 객체입니다. 이 객체 중 하나를 문자열과 비교한다면, String 객체가 문자열로 변환된 후 비교될 것입니다. 그러나 두 개의 피연산자 모두 String 객체라면, 객체로써 비교가 이루어지기 때문에 같은 값으로 취급되려면 같은 객체를 참조하고 있어야 합니다.
| ECMAScript® 2027 Language Specification # sec-equality-operators |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025년 6월 27일 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.