使用科学计数法进行表示。
使用了科学技术法之后,小数点后保留几位。
使用普通方法表示,小数点后保留几位。
console.log(new Number(10).toPrecision(3))
10.0
console.log(new Number(10000).toPrecision(3))
1.00e+4
console.log(new Number(0.1).toPrecision(3))
0.100
使用科学计数法进行表示。
使用了科学技术法之后,小数点后保留几位。
使用普通方法表示,小数点后保留几位。
console.log(new Number(10).toPrecision(3))
10.0
console.log(new Number(10000).toPrecision(3))
1.00e+4
console.log(new Number(0.1).toPrecision(3))
0.100