JavaScript toExponential() Method
Example
Convert a number into an exponential notation:
var num = 5.56789;
var n = num.toExponential();
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The toExponential() method converts a number into an exponential notation.
Browser Support
Method | |||||
---|---|---|---|---|---|
toExponential() | Yes | Yes | Yes | Yes | Yes |
Syntax
number.toExponential(x)
Parameter Values
Parameter | Description |
---|---|
x | Optional. An integer between 0 and 20 representing 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 |
Technical Details
Return Value: | A String, representing the number as an exponential notation |
---|---|
JavaScript Version: | ECMAScript 3 |
More Examples
Example
Convert a number into an exponential notation:
var num = 5.56789;
var n = num.toExponential(3);
Try it Yourself »
❮ JavaScript Number Reference