Run details:
Mozilla/5.0 (X11; Linux x86_64; rv:148.0) Gecko/20100101 Firefox/148.0
Firefox 148
Linux
Desktop
5 months ago
Using String.replace()
103/s
Using String.slice() without a pre-calculated suffix length
89/s
Using String.slice()
88/s
Using String.substring() with a magic number
86/s
Using String.substring() with a lastIndexOf() search
82/s
View exact numbers
Test name Executions per second
Using String.replace() 103 Ops/sec
Using String.slice() without a pre-calculated suffix length 89 Ops/sec
Using String.slice() 88 Ops/sec
Using String.substring() with a magic number 86 Ops/sec
Using String.substring() with a lastIndexOf() search 82 Ops/sec
Script Preparation code:
Tests: