厳密不等価 (!==)
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;
解説
例
オペランドが同じ型である場合の比較
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 GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Strict inequality ( a !== b ) |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.