Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:152.0) Gecko/20100101 Firefox/152.0
Firefox 152
Mac OS X 10.15
Desktop
28 days ago
Using String.replace()
125/s
Using String.substring() with a magic number
97/s
Using String.substring() with a lastIndexOf() search
95/s
Using String.slice() without a pre-calculated suffix length
31/s
Using String.slice()
29/s
View exact numbers
Test name Executions per second
Using String.replace() 125 Ops/sec
Using String.substring() with a magic number 97 Ops/sec
Using String.substring() with a lastIndexOf() search 95 Ops/sec
Using String.slice() without a pre-calculated suffix length 31 Ops/sec
Using String.slice() 29 Ops/sec
Script Preparation code:
Tests: