Set has vs Object lookup (v3)

Revision 3 of this benchmark created on


Setup

let set = new Set();
let obj = {};
for (let i=0; i<100; i++) {
	obj[i] = true;
	set.add(i);
}

Test runner

Ready to run.

Testing in
TestOps/sec
Set has
let n = 0;
for (let i=0; i<1000; i++) {
	if (set.has(i)) n++;
}
ready
Object lookup
let n = 0;
for (let i=0; i<1000; i++) {
	if (obj[i]) n++;
}
ready

Revisions

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