Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
Chrome 109
Mac OS X 10.15.7
Desktop
one month ago
Test name Executions per second
toFixed(4) 3464203.5 Ops/sec
(Math.round(*10000)/10000).toString() 5506236.5 Ops/sec
Script Preparation code:
AخA
 
var someFloat = 0.123456789;
Tests:
  • toFixed(4)

     
    Number(someFloat.toFixed(4));
  • (Math.round(*10000)/10000).toString()

    x
     
    (Math.round(someFloat*10000)/10000);