Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
List includes lookup
(version: 0)
Comparing performance of:
indexOf vs includes vs regex loose vs regex hard
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var ua = 'Mozilla 5.0' var botsArr = ['foobot', 'bar-bot', 'another-bot', 'bad-bot'] var botsRegex1 = /foobot|bar-bot|another-bot|bad-bot/i var botsRegex2 = /^(foobot|bar-bot|another-bot|bad-bot)$/i
Tests:
indexOf
botsArr.indexOf(ua) > -1
includes
botsArr.includes(ua)
regex loose
botsRegex1.test(ua)
regex hard
botsRegex2.test(ua)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
indexOf
includes
regex loose
regex hard
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
native find vs _.find
native find vs lodash _.find es6
lodash find vs native find
native find vs lodash _.find hey joe
abcdefg
Comments
Confirm delete:
Do you really want to delete benchmark?