The Object.is() method determines whether two values are the same value.
Return value: A Boolean indicating whether or not the two arguments are the same value.
I can test Object.is()
with simple types like:
Object.is('hello', 'hello'); // true
Object.is(1, 1); // true
Object.is(null, null); // true
I saw also on MDN that I can use it with "window" object like that:
Object.is(window, window); // true
When I tried to compare 2 simple "exact" values it seems not working (or maybe I'm using it in the wrong way)
Having those 2 simple objects:
var o1 = {a: "a"};
var o2 = {a: "a"};
All those comparisons returns false!
Object.is(o1, o2); // false
Object.is(o1, {a: "a"}); // false
Object.is({a: "a"}, {a: "a"}); // false
Can you help by explaining why the result is false or how I'm using Object.is()
in a wrong way?