扫码一下
查看教程更方便
javascript number toexponential 方法返回一个字符串,以指数表示法表示数字对象。
toexponential 方法的语法如下:
number.toexponential( [fractiondigits] )
fractiondigits 一个整数,指定小数点后的位数。默认为指定数字所需的位数。
返回 number object 的字符串表示,采用指数计数法,即小数点之前有一位数字,小数点之后有 num 位数字。该数字的小数部分将被舍入,必要时用 0 补足,以便它达到指定的长度。
所有主流浏览器都支持 toexponential 方法。
javascript method toexponential()
输出
num.toexponential() is : 7.71234e 1
num.toexponential(4) is : 7.7123e 1
num.toexponential(2) is : 7.71e 1
77.1234.toexponential()is:7.71234e 1
77 .toexponential() is : 7.71234e 1