JS keeps small examples of two decimal rounding functions

  • 2020-03-29 23:53:42
  • OfStack

Js rounds the function toFixed (), where the argument is the number of decimal places reserved.

<script language="javascript"> 
document.write("<h1>JS Keep the two decimal examples </h1><br>");  
var a=2.1512131231231321;    
document.write(" Original value: "+a+"<br>");    
document.write(" Two decimal places :"+a.toFixed(2)+"<br> Four digit decimal point "+a.toFixed(4)); 
</script> 

Related articles: