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

HTMLJavascriptProgramming Scripts

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>
raja
Published on 26-Feb-2018 12:58:06
Advertisements