Tests:
  • Regex

    AخA
     
    var x = 12.030303;
    x.toString().match(/^-?\d+(?:\.\d{0,2})?/)[0];
  • toFixed

     
    var x = 12.030303;
    x.toFixed(2);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Regex
    toFixed

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36
Chrome 99 on Windows
View result in a separate tab
Test name Executions per second
Regex 13440631.0 Ops/sec
toFixed 5468258.5 Ops/sec