- 0133技术站
- 联系QQ:18840023
- QQ交流群
- 微信公众号
toFixed()方法将数字格式化为小数点右侧的特定数字。
语法
number.toFixed( [digits] )
参数
● digits:小数点后显示的位数。
返回值
数字的字符串表示形式,不使用指数表示法,并且具有小数位后的确切位数。
例
var num3 = 177.234 console.log("num3.toFixed()是: "+num3.toFixed()) console.log("num3.toFixed(2)是: "+num3.toFixed(2)) console.log("num3.toFixed(6) 是: "+num3.toFixed(6))
输出:
num3.toFixed()是: 177 num3.toFixed(2)是: 177.23 num3.toFixed(6) 是: 177.234000
推荐手册