How to return a string value version of the current number?


The toLocaleString() method returns a string value version of the current number in a format that may vary according to a browser's local settings.

Example

You can try to run the following code to return a 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>

Updated on: 23-Jun-2020

137 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements