Includes vs Find

Benchmark created on


Setup

const locales = ["de", "en"];

const localesSet = new Set(locales);

Test runner

Ready to run.

Testing in
TestOps/sec
find
let language = locales.find(l => l === "de") ?? "en";
ready
includes
let language = locales.includes("de") ? "de" :"en";
ready
some
let language = locales.some(l => l === "de") ? "de" :"en";
ready
Set
let language = localesSet.has("de") ? "de" :"en";
ready

Revisions

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