Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript toExponential() Method

JavaScript toExponential() Method

Number Object Reference JavaScript Number object

Example

Convert the value of an object to exponential notation:

var num = 5.56789;

var n=num.toExponential()

n Output result:

Try it »


Definition and Usage

The toExponential() method converts the value of an object into exponential notation.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the toExponential() method.


Syntax

number

.toExponential(

x

)

Parameter value

Parameters Description
x Optional. Specifies the number of digits after the decimal point in exponential notation, a value between 0 and 20 inclusive; some implementations may support a larger range. If this parameter is omitted, as many digits as possible will be used.

Return Value

Type Description
String Returns the string representation of Number Object in exponential notation, that is, with one digit before the decimal point and num digits after it. The fractional part of the number is rounded, and padded with 0 if necessary, so that it reaches the specified length.

Technical Details

JavaScript version: 1.5

More examples

Example

In this example, we will convert a number into exponential notation:

var num = 5.56789;

var n=num.toExponential(3)

The output of the above example is:

Try it »


Number Object Reference JavaScript Number object