JavaScript Number toExponential()
Příklad 1
Převeďte číslo na exponenciální zápis:
let num = 5.56789;
let n = num.toExponential();
Definice a použití
Metoda toExponential() převádí číslo na exponenciální zápis.
Příklad 2
let num = 5.56789;
let n = num.toExponential(3);
Syntax
number.toExponential(x)
Parametry
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 |
Návratová hodnota
Řetězec představující číslo jako exponenciální zápis. |
Podpora prohlížeče
Number.constructor
je funkce ECMAScript3 (ES3).
ES3 (JavaScript 1999) je plně podporován ve všech prohlížečích:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |