Set vs Array - finding element

Benchmark created on


Setup

let ids = Array.from({ length: 1000000 }, (_, i) => i + 1);

const arr = [...ids]
const set = new Set(ids)

Test runner

Ready to run.

Testing in
TestOps/sec
Array
console.log(arr.includes(500000))
ready
Set
console.log(set.has(500000))
ready

Revisions

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