Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36
Chrome 97
Mac OS X 10.15.7
Desktop
3 years ago
Test name Executions per second
Intl.NumberFormat 845591.1 Ops/sec
toLocalString 14903486.0 Ops/sec
HTML Preparation code:
x
 
1
2
<script> window.formatter = new Intl.NumberFormat("en-US",{
3
    style: 'decimal',
4
    useGrouping: true,
5
    minimumFractionDigits: 0,
6
    maximumFractionDigits: 20,
7
  });</script>
Tests:
  • Intl.NumberFormat

     
    var a = formatter.format("10000000.1234");
  • toLocalString

     
    var a = "10000000.1234".toLocaleString("en-US",{
        style: 'decimal',
        useGrouping: true,
        minimumFractionDigits: 0,
        maximumFractionDigits: 20,
      });