| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Equality | [Back] [Original] |
Get to know MDN better
console.log(1 == 1);
// : true
console.log("hello" == "hello");
// : true
console.log("1" == 1);
// : true
console.log(0 == false);
// : true
x == y
(== !=) IsLooselyEqual
true true true +0 -0 NaN false NaN NaN true false true true true null undefined null undefined true false false true 1 false 0 2 NaN false NaN false BigInt() false A == B A B B == A
document.all undefined document.all == null true document.all === undefined && document.all === null false
1 == 1; // true
"hello" == "hello"; // true
"1" == 1; // true
1 == "1"; // true
0 == false; // true
0 == null; // false
0 == undefined; // false
0 == !!null; // true ( NOT )
0 == !!undefined; // true ( NOT )
null == undefined; // true
const number1 = new Number(3);
const number2 = new Number(3);
number1 == 3; // true
number1 == number2; // false
const object1 = {
key: "value",
};
const object2 = {
key: "value",
};
console.log(object1 == object2); // false
console.log(object1 == object1); // true
new String() String String
const string1 = "hello";
const string2 = String("hello");
const string3 = new String("hello");
const string4 = new String("hello");
console.log(string1 == string2); // true
console.log(string1 == string3); // true
console.log(string2 == string3); // true
console.log(string3 == string4); // false
console.log(string4 == string4); // true
const d = new Date("1995-12-17T03:24:00");
const s = d.toString(); // for example: "Sun Dec 17 1995 03:24:00 GMT-0800 (Pacific Standard Time)"
console.log(d == s); // true
const a = [1, 2, 3];
const b = "1,2,3";
a == b; // true `a`
const c = [true, 0.5, "hey"];
const d = c.toString(); // "true,0.5,hey"
c == d; // true
| ECMAScript 2027 LanguageSpecification # sec-equality-operators |
| Web Proxy Viewer | New URL | Original Page |