- The toPrecision() method returns the original number with no formatting.
 - Suppose Precision is not supplied or is undefined,the toString method is called instead.
 - Syntax
number.toPrecision(integer);
 
Code:-
- <html>
 - <head>
 - <meta name="viewport" content="width=device-width, initial-scale=1">
 - </head>
 - <body>
 - <h1>toPrecision()</h1>
 - <h2>77.366545</h2>
 - <input type="button" onclick="fun_pre();" value="toPrecision(4)">
 - <script>
 - function fun_pre()
 - {
 - var n1 = 77.366545;
 - alert("Precision : " + n1.toPrecision(4));
 - }
 - </script>
 - </body>
 - </html>
 
What is a to precision in JavaScript:- Geniusofstudent
 
        Reviewed by Network security
        on 
        
July 02, 2019
 
        Rating: 
      
 
        Reviewed by Network security
        on 
        
July 02, 2019
 
        Rating: 



No comments: