Número de JavaScript a Exponencial ()
Ejemplo 1
Convierta un número en una notación exponencial:
let num = 5.56789;
let n = num.toExponential();
Definición y uso
El método toExponential() convierte un número en una notación exponencial.
Ejemplo 2
let num = 5.56789;
let n = num.toExponential(3);
Sintaxis
number.toExponential(x)
Parámetros
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 |
Valor devuelto
Una cadena, que representa el número como una notación exponencial. |
Compatibilidad con navegador
Number.constructor
es una característica de ECMAScript3 (ES3).
ES3 (JavaScript 1999) es totalmente compatible con todos los navegadores:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |