The toExponential() method converts a number into an exponential notation.
The toExponential() method converts a number into an exponential notation.
number.toExponential(x)
Parameter | Require | Description |
---|---|---|
x | Optional. | An integer between 0 and 20, sets the number of digits in the notation after the decimal point. |
If omitted, it is set to as many digits as necessary to represent the value
A String, representing the number as an exponential notation
Convert a number into an exponential notation:
//display the exponential notation of a specified number. var num = 5.56789; var n = num.toExponential(); console.log(n);/* www .j av a 2s. c om*/ var n = num.toExponential(3); console.log(n);