The first value to compare
The second value to compare
True if the values are the same value, false otherwise
// Case 1: NaN
objIs(NaN, NaN); // true
NaN === NaN; // false
// Case 2: Signed zeros
objIs(0, -0); // false
objIs(+0, -0); // false
objIs(-0, -0); // true
0 === -0; // true
// Regular comparison
objIs('hello', 'hello'); // true
objIs('hello', 'goodbye'); // false
objIs(1, 1); // true
objIs(1, 2); // false
// Objects
const obj = { a: 1 };
objIs(obj, obj); // true
objIs(obj, { a: 1 }); // false (different objects with same content)
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: