False boolean check (v2)

Revision 2 of this benchmark created on


Setup

const data = [];

for (let i=0; i<10000; i++) {
	data.push(Math.round(Math.random() * 1000))
}


function isOdd(n) {
	return (n & 1) === 1;
}

Test runner

Ready to run.

Testing in
TestOps/sec
Not
for (let i=0; i<data.length; i++) {
	if (!isOdd(data[i])) {
		return false;
	}
}
ready
===
for (let i=0; i<data.length; i++) {
	if (isOdd(data[i]) === false) {
		return false;
	}
}
ready

Revisions

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