A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Strict_inequality below:

厳密不ç‰ä¾¡ (!==) - JavaScript | MDN

厳密不等価 (!==)

Baseline Widely available

厳密不等価演算子 (!==) は、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
構文 解説

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

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

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

例 オペランドが同じ型である場合の比較
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
オペランドが異なる型である場合の比較
console.log("3" !== 3); // true

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

console.log(null !== undefined); // true
オブジェクトの比較
const object1 = {
  name: "hello",
};

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

console.log(object1 !== object2); // true
console.log(object1 !== object1); // false
仕様書 ブラウザーの互換性 関連情報

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4