JavaScript-Zahl toExponential()
Beispiel 1
Wandeln Sie eine Zahl in eine Exponentialschreibweise um:
let num = 5.56789;
let n = num.toExponential();
Definition und Verwendung
Die Methode toExponential() wandelt eine Zahl in eine Exponentialschreibweise um.
Beispiel 2
let num = 5.56789;
let n = num.toExponential(3);
Syntax
number.toExponential(x)
Parameter
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 |
Rückgabewert
Ein String, der die Zahl als Exponentialschreibweise darstellt. |
Browser-Unterstützung
Number.constructor
ist eine ECMAScript3 (ES3)-Funktion.
ES3 (JavaScript 1999) wird in allen Browsern vollständig unterstützt:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |