Set.has vs Array.includes (v2)

Revision 2 of this benchmark created on


Setup

const size = 1000
const myArray = Array.from({length: size}).map((_, i) => i)
const mySet = new Set(myArray)
const toFind = Math.floor(size / 2)


Test runner

Ready to run.

Testing in
TestOps/sec
Array includes true
myArray.includes(toFind)
ready
Set has true
mySet.has(toFind)
ready
Array includes false
myArray.includes(size)
ready
Set has false
mySet.has(size)
ready

Revisions

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