Array indexof vs set has method

Benchmark created on


Preparation HTML

<script>
const arr = Array.from({length: 1000}, (x, i) => ++i)
const set = new Set([...arr])
</script>

Teardown

 

Test runner

Ready to run.

Testing in
TestOps/sec
Array indexof
arr.indexOf(750)
ready
Set has
set.has(750)
ready

Revisions

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