Numero JavaScript aEsponenziale()
Esempio 1
Converti un numero in una notazione esponenziale:
let num = 5.56789;
let n = num.toExponential();
Definizione e utilizzo
Il metodo toExponential() converte un numero in una notazione esponenziale.
Esempio 2
let num = 5.56789;
let n = num.toExponential(3);
Sintassi
number.toExponential(x)
Parametri
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 |
Valore di ritorno
Una stringa, che rappresenta il numero come notazione esponenziale. |
Supporto browser
Number.constructor
è una funzione ECMAScript3 (ES3).
ES3 (JavaScript 1999) è completamente supportato in tutti i browser:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |