Array.includes vs object lookup

Benchmark created on


Setup

const obj = {
	bar: true,
	baz: true,
	wow: true,
	ok: true
};
const arr = ['bar', 'baz', 'wow', 'ok'];
const key = 'baz';

Test runner

Ready to run.

Testing in
TestOps/sec
Array.includes

const has = arr.includes(key.toLowerCase())
ready
Object lookup
const has = obj[key.toLowerCase()]
ready

Revisions

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