Comparing array lookup methods

Benchmark created on


Setup

const LIMIT = 999999;
const arr = [...Array(LIMIT).keys()]
const findMe = Math.round(LIMIT / 2);

Test runner

Ready to run.

Testing in
TestOps/sec
.find()
arr.find(x => x === findMe)
ready
.indexOf()
arr.indexOf(findMe)
ready
Random access
arr[findMe]
ready

Revisions

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