读书人

Number的三个步骤

发布时间: 2012-06-30 17:20:12 作者: rapoo

Number的三个方法

toExponential

?

使用科学计数法进行表示。

?

使用了科学技术法之后,小数点后保留几位。

?

toFixed

?

使用普通方法表示,小数点后保留几位。

?

toPrecision

?

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

?

?

读书人网 >Web前端

热点推荐