How To Format a Number with Two Decimals | 您所在的位置:网站首页 › 视频应用软件有哪些可以随便看电影的 › How To Format a Number with Two Decimals |
How TO - Format a Number with Two Decimals
❮ Previous
Next ❯
Learn how to format a number with two decimals in JavaScript. Format a Number with Two DecimalsYou can use the toFixed() method to format a number to only show two decimals. Note that the result is rounded (shows 5.57 instead of 5.56): Example let num = 5.56789;let n = num.toFixed(2); // 5.57 Try it Yourself »If you want to display three decimals, just change the number to 3: Example let num = 5.56789;let n = num.toFixed(3); // 5.568 Try it Yourself »Tip: Learn more about the toFixed() method in our JavaScript Reference. ❮ Previous Next ❯ ★ +1 W3schools Pathfinder Track your progress - it's free! Log in Sign Up |
CopyRight 2018-2019 实验室设备网 版权所有 |