如何在JavaScript中以逗号将数字打印为数千个分隔符?

要将带有逗号的数字打印为数千个分隔符,请尝试运行以下代码-

示例

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

输出结果

24,287,995