Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Chrome 134
Mac OS X 10.15.7
Desktop
one month ago
Test name Executions per second
parseFloat() 19502350.0 Ops/sec
regex 12818797.0 Ops/sec
Tests:
  • parseFloat()

    AخA
     
    var string = parseFloat((3/2).toFixed(4)).toString();
  • regex

     
    var string = (3/2).toFixed(4).replace(/\.?0*$/, '');