Test the performance of replace() vs substring() vs slice() when replacing a char at the beginning of a (in this case uri query-)string that may or may not be there.
Added the combined brackets[ ] + substr() method, since it's always the first char we wan't to pop off.
Inspired by https://jsperf.com/replace-or-substr.
Note: could not get 'let' and 'const' to work. Well, too bad...
Comparing performance of: substring and substring vs replace inline regex
Memory measurements supported only in Chrome.
For precise memory measurements Chrome must be launched with --enable-precise-memory-info flag.
More information: Monitoring JavaScript Memory
Test case name
Result
substring and substring
replace inline regex
Fastest:N/A
Slowest:N/A
ⓘGet performance results from real users on your website with Request Metrics.
Latest run results:
Run details: (Test run date:
9 months ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36