在JavaScript中 Number对象toPrecision方法
toPrecision方法用于在JavaScript中将数字格式化为指定长度。
此方法用于为指定长度添加小数点。
语法
number.toPrecision(x)
var num = new Number(13.3714); var n = num.toPrecision(2); console.log(n); // 13
日期:2020-04-18 01:09:31 来源:oir作者:oir
toPrecision方法用于在JavaScript中将数字格式化为指定长度。
此方法用于为指定长度添加小数点。
number.toPrecision(x)
var num = new Number(13.3714); var n = num.toPrecision(2); console.log(n); // 13