如何返回当前号码的字符串值版本?

htmljavascriptprogramming scripts

toLocaleString() 方法返回当前号码的字符串值版本,其格式可能因浏览器的本地设置而异。

示例

您可以尝试运行以下代码来返回字符串值版本 −

<html>
   <head>
      <title>JavaScript toLocaleString() 方法 </title>
   </head>

   <body>
        <script>
         var num = new Number(150.1234);
         document.write( num.toLocaleString());
      </script>
   </body>
</html>

相关文章