Equality Comparisons (v15)

Revision 15 of this benchmark created on


Setup

const numbers = [];
const numbersNan = [];
const booleans = [];
const strings = [];
const objs = [];
const objsMega = [];

for(let i=0; i<1000; i++) {
	numbers.push(i);
	numbersNan.push(i%2 ? Number.NaN: 1);
	booleans.push(i%2 == 0);
	strings.push('' + i);
	objs.push({});
	objsMega.push({
		['_' + i]: i
	});
}

Test runner

Ready to run.

Testing in
TestOps/sec
numbers ==
let sum = false;
for (let i = 0; i< numbers.length; i++) {
	sum ||= numbers[i] == numbers.at(-i - 1);
}
ready
numbers ===
let sum = false;
for (let i = 0; i< numbers.length; i++) {
	sum ||= numbers[i] === numbers.at(-i - 1);
}
ready
strings ==
let sum = false;
for (let i = 0; i< strings.length; i++) {
	sum ||= strings[i] == strings.at(-i - 1);
}
ready
strings ===
let sum = false;
for (let i = 0; i< strings.length; i++) {
	sum ||= strings[i] === strings.at(-i - 1);
}
ready
objs ==
let sum = false;
for (let i = 0; i< objs.length; i++) {
	sum ||= objs[i] == objs.at(-i - 1);
}
ready
objs ===
let sum = false;
for (let i = 0; i< objs.length; i++) {
	sum ||= objs[i] === objs.at(-i - 1);
}
ready
objsMega ==
let sum = false;
for (let i = 0; i< objsMega.length; i++) {
	sum ||= objsMega[i] == objsMega.at(-i - 1);
}
ready
objsMega ===
let sum = false;
for (let i = 0; i< objsMega.length; i++) {
	sum ||= objsMega[i] === objsMega.at(-i - 1);
}
ready
numbersNan ==
let sum = false;
for (let i = 0; i< numbersNan.length; i++) {
	sum ||= numbersNan[i] == numbersNan.at(-i - 1);
}
ready
numbersNan ===
let sum = false;
for (let i = 0; i< numbersNan.length; i++) {
	sum ||= numbersNan[i] === numbersNan.at(-i - 1);
}
ready
null ==
let sum = false;
for (let i = 0; i< numbersNan.length; i++) {
    sum ||= numbers[i] == null;
	sum ||= numbersNan[i] == null;
	sum ||= booleans[i] == null;
	sum ||= strings[i] == null;
	sum ||= objs[i] == null;
	sum ||= objsMega[i] == null;
}
ready
null === || undefined ===
let sum = false;
for (let i = 0; i< numbersNan.length; i++) {
    sum ||= numbers[i] === null || numbers[i] === undefined;
	sum ||= numbersNan[i] === null || numbersNan[i] === undefined;
	sum ||= booleans[i] === null || booleans[i] === undefined;
	sum ||= strings[i] === null || strings[i] === undefined;
	sum ||= objs[i] === null || objs[i] === undefined;
	sum ||= objsMega[i] === null || objsMega[i] === undefined;
}
ready

Revisions

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