Set.has vs Array.includes performance for short sizes

Benchmark created on


Setup

const allowedSet = new Set(["search", "number", "email"]);
const allowedArray = ["search", "number", "email"];

Test runner

Ready to run.

Testing in
TestOps/sec
Set.has
allowedSet.has("email")
ready
Array.includes
allowedArray.includes("email")
ready
Set.has inline
new Set(["search", "number", "email"]).has("email")
ready
Array.includes inline
["search", "number", "email"].includes("email")
ready

Revisions

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