Run details:
Mozilla/5.0 (iPhone; CPU iPhone OS 14_8 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Mobile/15E148 Safari/604.1
Mobile Safari 14
iOS 14.8
Mobile
2 years ago
Test name Executions per second
replace 129985.7 Ops/sec
replaceAll 119195.2 Ops/sec
replace in a loop without g flag 3559.7 Ops/sec
replace in a loop, count matches with g flag, replace without g flag 5054.9 Ops/sec
Script Preparation code:
Tests:
  • replace

  • replaceAll

  • replace in a loop without g flag

  • replace in a loop, count matches with g flag, replace without g flag