Set.has() vs Array.includes() (v12)

Revision 12 of this benchmark created on


Description

Compare Set.has() vs Array.includes() performance

Setup

const arr = [...Array(1_000_000).keys()]
const set = new Set(arr)

Test runner

Ready to run.

Testing in
TestOps/sec
set.has()
const isIn = set.has(1) && set.has(2) && set.has(3) && set.has(4) && set.has(5);
ready
array.includes()
const isIn = arr.includes(1) && arr.includes(2) && arr.includes(3) && arr.includes(4) && arr.includes(5);
ready

Revisions

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