Latest web development tutorials

JavaScript toExponential () method

Number Object Reference JavaScript Number Object

Examples

Converting the value of an object is exponential notation:

var num = 5.56789;
var n=num.toExponential()

n output:


try it"

Definition and Usage

toExponential () method to convert the value of an object into exponential notation.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support toExponential () method


grammar

number.toExponential( x )

Parameter Value

参数 描述
x 可选。规定指数计数法中的小数位数,是 0 ~ 20 之间的值,包括 0 和 20,有些实现可以支持更大的数值范围。如果省略了该参数,将使用尽可能多的数字。

return value

类型 描述
String 返回 Number Object 的字符串表示,采用指数计数法,即小数点之前有一位数字,小数点之后有 num 位数字。该数字的小数部分将被舍入,必要时用 0 补足,以便它达到指定的长度。

technical details

JavaScript version: 1.5


More examples

Examples

In this case, we will convert to a digital exponential notation:

var num = 5.56789;
var n=num.toExponential(3)

Examples of the above output:


try it"


Number Object Reference JavaScript Number Object