var PI = 1213.141592653; // 常量大寫 console.log(PI.toFixed(2)); console.log(parseInt(PI * 100) / 100); var str = PI + ""; // 因為數字沒法進行字符操作 先轉換 console.log(str.substr(0, str.indexOf(".") + 3));
var PI = 1213.141592653; // 常量大寫 console.log(PI.toFixed(2)); console.log(parseInt(PI * 100) / 100); var str = PI + ""; // 因為數字沒法進行字符操作 先轉換 console.log(str.substr(0, str.indexOf(".") + 3));
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。