What is a to precision in JavaScript:- Geniusofstudent

  • 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:-

  • <!DOCTYPE html> 
    1. <html> 
    2.  
    3. <head> 
    4.  <meta name="viewport" content="width=device-width, initial-scale=1"> 
    5. </head> 
    6.  
    7. <body> 
    8.  <h1>toPrecision()</h1> 
    9.  <h2>77.366545</h2> 
    10.  
    11.  <input type="button" onclick="fun_pre();" value="toPrecision(4)"> 
    12.  
    13.  <script> 
    14.   function fun_pre() 
    15.   { 
    16.    var n1 = 77.366545; 
    17.    alert("Precision : " + n1.toPrecision(4)); 
    18.   } 
    19.  </script> 
    20.  
    21. </body> 
    22.  
    23. </html>
    What is a to precision in JavaScript:- Geniusofstudent What is a to precision in JavaScript:- Geniusofstudent Reviewed by Network security on July 02, 2019 Rating: 5

    No comments:

    Useful Information

    Powered by Blogger.