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删除。