Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
sillyString
(version: 0)
Comparing performance of:
slice vs regex
Created:
2 years ago
by:
Guest
Jump to the latest result
Tests:
slice
const word = "Hello World"; const vowels = 'aeiou'; let newWord = ''; word.split('').forEach((index, i ) => { if (vowels.includes(word[i])) { newWord += word.slice(i, i+1) + 'b' + word[i]; } else { newWord += word.slice(i, i+1); } }); console.log(newWord);
regex
const word = "Hello World"; return word.replace(/[aeiou]/gi, (match) => match + 'b' + match);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
slice
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!
Related benchmarks:
toFixed vs Math.round() - result as a number
toFixed() vs Math.round().toString()
string-interpolation-vs-toString
string-interpolation-vs-toString-vs-plus-string
toFixed vs Math.round() with numbers
Comments
Confirm delete:
Do you really want to delete benchmark?