string comparison vs array lookup

Benchmark created on


Setup

const foo = 'bar';
const biz = ['baz'];

Test runner

Ready to run.

Testing in
TestOps/sec
string compare first
if (foo === 'notbar' || biz.includes('notbaz')) {
	return true;
} 
ready
array check first
if (biz.includes('notbaz') || foo === 'notbar') {
	return true;
}
ready

Revisions

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