Nombre JavaScript toExponential()
Exemple 1
Convertissez un nombre en une notation exponentielle :
let num = 5.56789;
let n = num.toExponential();
Définition et utilisation
La méthode toExponential() convertit un nombre en une notation exponentielle.
Exemple 2
let num = 5.56789;
let n = num.toExponential(3);
Syntaxe
number.toExponential(x)
Paramètres
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 |
Valeur de retour
Une chaîne, représentant le nombre sous forme de notation exponentielle. |
Prise en charge du navigateur
Number.constructor
est une fonctionnalité ECMAScript3 (ES3).
ES3 (JavaScript 1999) est entièrement pris en charge dans tous les navigateurs :
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |