Numer JavaScript do wykładniczy()
Przykład 1
Przekształć liczbę w notację wykładniczą:
let num = 5.56789;
let n = num.toExponential();
Definicja i użycie
Metoda toExponential() konwertuje liczbę na notację wykładniczą.
Przykład 2
let num = 5.56789;
let n = num.toExponential(3);
Składnia
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 |
Wartość zwrotu
String, reprezentujący liczbę jako notację wykładniczą. |
Obsługa przeglądarki
Number.constructor
to funkcja ECMAScript3 (ES3).
ES3 (JavaScript 1999) jest w pełni obsługiwany we wszystkich przeglądarkach:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |