This page was translated from English by the community.Learn more and join the MDN Web Docs community.
일치 연산자 (===)
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015년 7월.
일치 연산자 (===) 는 두 피연산자가 동일한지 확인하며, 불리언 결과를 반환합니다.동등 연산자와는 다르게,일치 연산자는 두 피연산자의 타입이 다르면 동일하지 않다고 여깁니다.
In this article
시도해 보기
console.log(1 === 1);// Expected output: trueconsole.log("hello" === "hello");// Expected output: trueconsole.log("1" === 1);// Expected output: falseconsole.log(0 === false);// Expected output: false문법
js
x === y설명
일치 연산자 (=== 와!==)는 두 피연산자를 비교하기 위해엄격한 같음을 사용합니다.
- 두 피연산자의 타입이 다르면,
false를 반환합니다. - 두 피연산자가 모두 객체이면, 두 객체가 동일한 객체를 참조할 경우에만
true를 반환합니다. - 두 피연산자가 모두
null이거나undefined인 경우,true를 반환합니다. - 피연산자 중 하나가
NaN라면,false를 반환합니다. - 그렇지 않은 경우에는, 두 피연산자의 값을 비교합니다.
- 숫자는 같은 숫자 값이어야 합니다.
+0과-0은 동일한 값으로 여깁니다. - 문자열은 동일한 문자가 같은 순서로 구성되어 있어야 합니다.
- 불리언은 둘 다
true이거나false여야 합니다.
- 숫자는 같은 숫자 값이어야 합니다.
일치 연산자와동등 연산자(==)의 가장 눈에 띄는 차이점은 피연산자들의 타입이 다를 경우,== 연산자는 비교하기 전에 같은 타입으로 변환을 시도한다는 점입니다.
예제
>같은 타입의 피연산자 비교
js
"hello" === "hello"; // true"hello" === "hola"; // false3 === 3; // true3 === 4; // falsetrue === true; // truetrue === false; // falsenull === null; // true다른 타입의 피연산자 비교
js
"3" === 3; // falsetrue === 1; // falsenull === undefined; // false3 === new Number(3); // false객체 간의 비교
js
const object1 = { key: "value",};const object2 = { key: "value",};console.log(object1 === object2); // falseconsole.log(object1 === object1); // true명세서
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-equality-operators> |