toExponential method
The toExponential method
converts a number to exponential
notation. Optional parameter - the
number of digits after the decimal
point, if it is not present, then
as many digits after the decimal
point as necessary for representation
will be displayed.
Syntax
number.toExponential([number of digits after the decimal point]);
Example
In this example, the exponential
notation of the number 5
was output:
let num = 5;
console.log(num.toExponential());
The code execution result:
5e+0
Example
In this example, the exponential
notation of the number 5
with 3 decimal places was
output:
let num = 5;
console.log(num.toExponential(3));
The code execution result:
5.000e+0