Computer >> Computer tutorials >  >> Programming >> Javascript

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


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