JavaScript Number toExponential() method
- Vorherige Seite prototype
- Nächste Seite toFixed()
- Zurück zur übergeordneten Ebene JavaScript Number Referenzhandbuch
Definition and usage
toExponential()
The method converts a number to exponential notation.
Instance
Example 1
let num = 5.56789; let n = num.toExponential(3);
Example 2
Convert a number to exponential notation:
let num = 5.56789; let n = num.toExponential();
Syntax
number.toExponential(digits)
Parameter
Parameter | Description |
---|---|
digits |
Optional. An integer between 0 and 20, specifying the number of decimal places in exponential notation. If omitted, it is set to the number of digits required to represent the value. |
Return value
Type | Description |
---|---|
String | Representing numbers in exponential notation. |
Technical details
Return value
Returns a string representation of Number using exponential notation, with one digit before the decimal point and digits Number of digits. The decimal part of the number will be rounded and, if necessary, padded with zeros to reach the specified length.
Thrown
Exception | Description |
---|---|
RangeError |
When digits Exception thrown when too small or too large. Values between 0 and 20 do not trigger this exception. Some implementations support a wider or narrower range of values. |
TypeError | Exception thrown if the object calling this method is not a Number. |
Browser support
Number.constructor
Ist eine ECMAScript3 (ES3)-Eigenschaft.
Alle Browser unterstützen ES3 (JavaScript 1999):
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Unterstützung | Unterstützung | Unterstützung | Unterstützung | Unterstützung | Unterstützung |
- Vorherige Seite prototype
- Nächste Seite toFixed()
- Zurück zur übergeordneten Ebene JavaScript Number Referenzhandbuch