Skip to content

JavaScript number format currency | Example code

  • by

Use NumberFormat to get the number format currency in JavaScript. This is part of the Internationalization API. This constructor creates Intl.NumberFormat objects that enable language-sensitive number formatting.

Example get number format currency in JavaScript

simple example code.

<!DOCTYPE html>
<html>
<body>

  <script>

   var formatter = new Intl.NumberFormat('en-US', {
    style: 'currency',
    currency: 'USD',});

   console.log(formatter.format(2500)); 
   console.log(formatter.format(1000000)); 
 </script>

</body>
</html>

Output:

JavaScript number format currency

Do comment if you have any doubts or suggestions on this JS format currency topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading