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: falseconsole.log("hello" != "hello");// Expected output: falseconsole.log("1" != 1);// Expected output: falseconsole.log(0 != false);// Expected output: false구문
js
x != y;설명
부등식 연산자는 피연산자가 같지 않은지 여부를 확인합니다.동등 연산자의 부정이므로 다음 두 줄은 항상 같은 결과를 제공합니다.
js
x != y;!(x == y);비교 알고리즘에 대한 자세한 내용은동등 연산자 페이지를 참조하십시오.
동등 연산자와 마찬가지로 부등 연산자도 다른 유형의 피연산자를 변환하여 비교합니다.
js
3 != "3"; // false이를 방지하고 다른 유형이 다른 것으로 간주되게 하려면엄격한 불일치 연산자를 사용해야 합니다.
js
3 !== "3"; // true예제
>타입 변환이 없는 비교
js
1 != 2; // true"hello" != "hola"; // true1 != 1; // false"hello" != "hello"; // false타입 변환이 있는 비교
js
"1" != 1; // false1 != "1"; // false0 != false; // false0 != null; // true0 != undefined; // true0 != !!null; // false, look at Logical NOT operator0 != !!undefined; // false, look at Logical NOT operatornull != undefined; // falseconst number1 = new Number(3);const number2 = new Number(3);number1 != 3; // falsenumber1 != number2; // true객체의 비교
js
const object1 = { key: "value" };const object2 = { key: "value" };object1 != object2; // trueobject2 != object2; // false명세
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-equality-operators> |