无涯教程-toExponential()函数

67 阅读1分钟

此方法返回一个以指数表示形式表示数字对象的字符串。

toExponential() - 语法

number.toExponential( [fractionDigits] )
  • fractionDigits     -  一个整数,指定小数点后的位数。

toExponential() - 返回值

一个字符串,以指数表示形式表示Number 对象,其小数点前有一位数字,四舍五入为小数点后的fractionDigits数字,如果省略fractionDigits参数,则小数点后的位数默认为唯一表示该值所必需的位数。

toExponential() - 示例

//toExponential() 
var num1=1225.30 
var val=num1.toExponential(); 
console.log(val)

运行上面代码输出

1.2253e+

参考链接

www.learnfk.com/es6/es6-toe…