本文转自:https://blog.csdn.net/qq_40171039/article/details/79729503
保留两位小数且不四舍五入:
方法一:
var a = 2.461;
var b = ( parseInt( a * 100 ) / 100 ).toFixed(2);
console.log(b); // 2.46
方法二:
var a = -12.45;
var b = parseFloat(a).toFixed(3);
var result = b.substring(0, b.tostring()length-1)
console.log(result) // -12.4
---------------------
作者:全栈大诗
来源:CSDN
原文:https://blog.csdn.net/qq_40171039/article/details/79729503
版权声明:本文为博主原创文章,转载请附上博文链接!