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 (X11; Ubuntu; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0
Browser:
Firefox 130
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Array.includes
16777992.0 Ops/sec
String.match
7783579.0 Ops/sec
Multiple if Conditions
346353664.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') {}