Object.is vs ===

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Object.is
Object.is(25, 25); // true
Object.is("foo", "foo"); // true
Object.is("foo", "bar"); // false
Object.is(null, null); // true
Object.is(undefined, undefined); // true
Object.is(window, window); // true
Object.is([], []); // false
const foo = { a: 1 };
const bar = { a: 1 };
const sameFoo = foo;
Object.is(foo, foo); // true
Object.is(foo, bar); // false
Object.is(foo, sameFoo); // true

// Case 2: Signed zero
Object.is(0, -0); // false
Object.is(+0, -0); // false
Object.is(-0, -0); // true

// Case 3: NaN
Object.is(NaN, 0 / 0); // true
Object.is(NaN, Number.NaN); // true
ready
===
25 === 25; // true
"foo" === "foo"; // true
"foo" === "bar"; // false
null === null; // true
undefined === undefined; // true
window === window; // true
[] === []; // false
const foo = { a: 1 };
const bar = { a: 1 };
const sameFoo = foo;
foo === foo; // true
foo === bar; // false
foo === sameFoo; // true

// Case 2: Signed zero
0 === -0; // false
+0 === -0; // false
-0 === -0; // true

// Case 3: NaN
NaN === 0 / 0; // true
NaN === Number.NaN; // true
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.