Array.includes vs object lookup vs set (v2)

Revision 2 of this benchmark created on


Setup

const obj = {
	bar: true,
	baz: true,
	wow: true,
	ok: true
};
const arr = ['bar', 'baz', 'wow', 'ok'];
const set = new Set(arr);
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
Set
const has = set.has(key.toLowerCase())
ready

Revisions

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