Home  >  Article  >  Web Front-end  >  How can I return the current number as a string value version?

How can I return the current number as a string value version?

王林
王林forward
2023-09-12 10:13:081228browse

How can I return the current number as a string value version?

toLocaleString() method returns a string value version of the current number, whose format may vary based on the browser's local settings.

Example

You can try running the following code to return the string value version -

<html>
   <head>
      <title>JavaScript toLocaleString() Method </title>
   </head>

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

The above is the detailed content of How can I return the current number as a string value version?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete