Set vs Array inclusion check

Benchmark created on


Setup

const alphabetArray = Array.from({ length: 26 }, (_, i) => String.fromCharCode(97 + i));
const alphabetSet = new Set(alphabetArray)

Test runner

Ready to run.

Testing in
TestOps/sec
Set
alphabetSet.has('j')
ready
Array
alphabetArray.includes('j')
ready

Revisions

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