Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Javascript: Case insensitive string comparison indexOf vs includes
(version: 0)
Comparing performance of:
toLowerCase() vs Regex
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
const words = Array.from({ length: 1000 }, (_, i) => `word${i + 1}`); const searchString = "WORD512"; const searchStringRegex = new RegExp(request.query, 'i');
Tests:
toLowerCase()
words.filter(word => word.toLowerCase().includes(searchString));
Regex
words.filter(word => searchStringRegex.indexOf(word));
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
toLowerCase()
Regex
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!
Comments
Confirm delete:
Do you really want to delete benchmark?