Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array.includes vs String.match
Matching a string against more than one possibility.
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Array.includes
23219594.0 Ops/sec
String.match
5114760.5 Ops/sec
Multiple if Conditions
58157956.0 Ops/sec
Tests:
Array.includes
const testStrFirst = 'foo'; ['foo', 'bar'].includes(testStrFirst); const testStrSecond = 'bar'; ['foo', 'bar'].includes(testStrSecond); const testStrNotMatch = 'baz'; ['foo', 'bar'].includes(testStrNotMatch);
String.match
const testStrFirst = 'foo'; testStrFirst.match(/^(foo|bar)$/); const testStrSecond = 'bar'; testStrSecond.match(/^(foo|bar)$/); const testStrNotMatch = 'baz'; testStrNotMatch.match(/^(foo|bar)$/);
Multiple if Conditions
const testStrFirst = 'foo'; if (testStrFirst == 'foo' || testStrFirst == 'bar') {} const testStrSecond = 'bar'; if (testStrFirst == 'foo' || testStrFirst == 'bar') {} const testStrNotMatch = 'baz'; if (testStrFirst == 'foo' || testStrFirst == 'bar') {}