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_equality below:

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

厳密等価 (===)

Baseline Widely available

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

試してみましょう
console.log(1 === 1);
// Expected output: true

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

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

console.log(0 === false);
// Expected output: false
構文 解説

厳密等価演算子 (=== および !==) は、厳密等価比較アルゴリズムを使用して 2 つのオペランドを比較します。

この演算子と等価 (==) 演算子の最も顕著な違いは、オペランドの型が異なる場合、 == 演算子は比較前に同じ型に変換しようとすることです。

例 オペランドが同じ型である場合の比較
console.log("hello" === "hello"); // true
console.log("hello" === "hola"); // false

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

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

console.log(null === null); // true
オペランドが異なる型である場合の比較
console.log("3" === 3); // false

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

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

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

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

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