How to print a number with commas as thousands of separators in JavaScript?

JavascriptWeb DevelopmentFront End Technology

To print a number with commas as thousands of separators, try to run the following code −

Example

Live Demo

<!DOCTYPE html>
<html>
   <body>
      <script>
         var number = 24287995;
         document.write(new Intl.NumberFormat().format(number));
      </script>
   </body>
</html>

Output

24,287,995
raja
Ali
Published on 03-Feb-2018 15:36:02
Advertisements