Javascript examples for Number:toFixed
Convert a number which has fewer decimal places than requested:
<!DOCTYPE html> <html> <body> <p>Click the button to display the fixed number.</p> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w ww .j a v a2 s.c om var num = 5.56789; var n = num.toFixed(10) document.getElementById("demo").innerHTML = n; } </script> </body> </html>