Set.has() vs Array.includes() (v6)

Revision 6 of this benchmark created on


Description

Compare Set.has() vs Array.includes() performance

Setup

const arr = [];
for (i = 0; i < 10_000; i++) {
	arr.push(i);
}
const set = new Set(arr);

Test runner

Ready to run.

Testing in
TestOps/sec
Set.has()
const isIn = set.has(1) && set.has(2) && set.has(10000) && set.has(4000) && set.has(9999);
ready
Array.includes()
const isIn = arr.includes(1) && arr.includes(2) && arr.includes(10000) && arr.includes(4000) && arr.includes(9999);
ready

Revisions

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