js四舍五入保留保留两位小数

js四舍五入保留保留两位小数  tofixed()

var num = 1.123456887755412;

console.log('保留两位小数:'+num.tofixed(2)+'-----保留四位小数"+num.tofixed(4))

猜你喜欢

转载自www.cnblogs.com/Chestnut-LYN/p/10605878.html