Equals: `===` vs `Object.is`

Benchmark created on


Setup

const a = new Array(1000)
const b = new Array(1000)
for (let i = 0; i < 1000; i++) {
	const x = i % 2 ? {obj:true} : i
	a[i] = x
	b[i] = x
}

Test runner

Ready to run.

Testing in
TestOps/sec
a === b
let res = 0

for (let i = 0; i < a.length; i++) {
	for (let j = 0; j < b.length; j++) {
		if (a[i] === b[i]) {
			res++
		}
	}
}

return res
ready
Object.is(a, b)
let res = 0

for (let i = 0; i < a.length; i++) {
	for (let j = 0; j < b.length; j++) {
		if (Object.is(a[i], b[i])) {
			res++
		}
	}
}

return res
ready

Revisions

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