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

Revision 10 of this benchmark created on


Description

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

Test runner

Ready to run.

Testing in
TestOps/sec
Set.has()
const arr = Array.from({ length: 1_000_000 }, (_, i) => i);
const set = new Set();
arr.map(item => set.add(item));
const isIn = set.has(1) && set.has(2) && set.has(3) && set.has(4) && set.has(5);
ready
Array.includes()
const arr = Array.from({ length: 1_000_000 }, (_, i) => i);
const isIn = arr.includes(1) && arr.includes(2) && arr.includes(3) && arr.includes(4) && arr.includes(5);
ready

Revisions

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