array includes vs regex match

Benchmark created on


Setup

const arr = Array.from({ length: 20 }, (_, i) => `word${i}`);
const pattern = /banana/;

Test runner

Ready to run.

Testing in
TestOps/sec
array includes

const searchValue = "word19";
arr.includes(searchValue);
ready
regex
const text = "apple banana cherry";

pattern.test(text);
ready

Revisions

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