Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 Edg/139.0.0.0
Chrome 139
Windows
Desktop
11 months ago
Using String.slice() without a pre-calculated suffix length
970/s
Using String.slice()
965/s
Using String.substring() with a magic number
958/s
Using String.substring() with a lastIndexOf() search
437/s
Using String.replace()
374/s
View exact numbers
Test name Executions per second
Using String.slice() without a pre-calculated suffix length 970 Ops/sec
Using String.slice() 965 Ops/sec
Using String.substring() with a magic number 958 Ops/sec
Using String.substring() with a lastIndexOf() search 437 Ops/sec
Using String.replace() 374 Ops/sec
Script Preparation code:
Tests: