<script> var pi = 3.143592653; var str = pi+""; console.log(str.substr(0,str.indexOf(".")+3)); console.log(parseInt(pi*100)/100); console.log(pi.toFixed(2)); </script>
保留两位小数
最新推荐文章于 2023-09-26 20:31:11 发布
<script> var pi = 3.143592653; var str = pi+""; console.log(str.substr(0,str.indexOf(".")+3)); console.log(parseInt(pi*100)/100); console.log(pi.toFixed(2)); </script>