The objIs() method determines whether two values are the same value.
Two values are the same if one of the following holds:
This is different from the === operator in that:
0.11.9
// Case 1: NaNobjIs(NaN, NaN); // trueNaN === NaN; // false// Case 2: Signed zerosobjIs(0, -0); // falseobjIs(+0, -0); // falseobjIs(-0, -0); // true0 === -0; // true// Regular comparisonobjIs('hello', 'hello'); // trueobjIs('hello', 'goodbye'); // falseobjIs(1, 1); // trueobjIs(1, 2); // false// Objectsconst obj = { a: 1 };objIs(obj, obj); // trueobjIs(obj, { a: 1 }); // false (different objects with same content) Copy
// Case 1: NaNobjIs(NaN, NaN); // trueNaN === NaN; // false// Case 2: Signed zerosobjIs(0, -0); // falseobjIs(+0, -0); // falseobjIs(-0, -0); // true0 === -0; // true// Regular comparisonobjIs('hello', 'hello'); // trueobjIs('hello', 'goodbye'); // falseobjIs(1, 1); // trueobjIs(1, 2); // false// Objectsconst obj = { a: 1 };objIs(obj, obj); // trueobjIs(obj, { a: 1 }); // false (different objects with same content)
The first value to compare
The second value to compare
True if the values are the same value, false otherwise
The objIs() method determines whether two values are the same value.
Two values are the same if one of the following holds:
This is different from the === operator in that:
Since
0.11.9
Example