← All benchmarksJavaScript
JavaScript Array.includes vs Set.has: 386.6 ms vs 0.56 ms
Is Set.has faster than Array.includes in JavaScript?
In Node 22, 10,000 lookups in 100,000 items took 386.6 ms with Array.includes and 0.56 ms with Set.has, about 690x faster.
Results
| Array.includes | 386.6 ms |
|---|---|
| Set.has | 0.56 ms |
How it was measured
100,000 numbers, 10,000 lookups near the end, best of 5.
const set = new Set(arr);
set.has(x);Why
includes scans linearly; Set uses hashing.
When this does not apply
Tiny arrays: no difference.
Environment
MacBook Air (Apple silicon, 8 cores), macOS, Node 22. Measured 2026-10-12.
Source: shorts/demo-ticket/w3/lookup.mjs in my content-engine repository. Treat any single run as a direction; re-run it on your hardware.
Related
By Josué Barros, senior software engineer (full-stack, data and AI).