RegExp vs Includes

Benchmark created on


Setup

const choices = ['hunter', 'warlock', 'titan'];

Test runner

Ready to run.

Testing in
TestOps/sec
RegExp
const choice = Math.floor(Math.random() * choices.length);
(/hunter/i).test(choices[choice]);
ready
Includes
const choice = Math.floor(Math.random() * choices.length);


choices[choice].toLowerCase().includes('hunter');
ready

Revisions

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