Object vs Set

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Object
const lookup = {};
const id = 12;
let found = false;
for (let i = 0; i < 100; i++) {
	lookup[i] = true;
}

if (lookup[id]) {
	found = true;
}
ready
Set
const lookup = new Set();
const id = 12;
let found = false;
for (let i = 0; i < 100; i++) {
	lookup.add(i)
}

if (lookup.has(id)) {
	found = true;
}
ready

Revisions

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