厳密不等価 (!==)

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

厳密不等価演算子 (!==) は、2 つのオペランドが等しくないことを検査し、論理値で結果を返します。不等価演算子とは異なり、厳密不等価演算子はオペランドの型が異なる場合、常に異なると判断します。

試してみましょう

console.log(1 !== 1);
// Expected output: false

console.log("hello" !== "hello");
// Expected output: false

console.log("1" !== 1);
// Expected output: true

console.log(0 !== false);
// Expected output: true

構文

js
x !== y;

解説

厳密不等価演算子は、オペランドが等しくないことを検査します。これは厳密等価演算子の逆に当たるので、以下の 2 行は常に同じ結果になります。

js
x !== y;

!(x === y);

比較アルゴリズムの詳細については、厳密等価演算子のページを参照して下さい。

厳密等価演算子と同様に、厳密不等価演算子はオペランドの型が異なると、常に異なるものと見なします。

js
3 !== "3"; // true

オペランドが同じ型である場合の比較

js
console.log("hello" !== "hello"); // false
console.log("hello" !== "hola"); // true

console.log(3 !== 3); // false
console.log(3 !== 4); // true

console.log(true !== true); // false
console.log(true !== false); // true

console.log(null !== null); // false

オペランドが異なる型である場合の比較

js
console.log("3" !== 3); // true

console.log(true !== 1); // true

console.log(null !== undefined); // true

オブジェクトの比較

js
const object1 = {
  name: "hello",
};

const object2 = {
  name: "hello",
};

console.log(object1 !== object2); // true
console.log(object1 !== object1); // false

仕様書

Specification
ECMAScript® 2025 Language Specification
# sec-equality-operators

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
Strict inequality (a !== b)

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報