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

javascriptnumber.toExponential([number of digits after the decimal point]);

Example

In this example, the exponential notation of the number 5 was output:

javascriptlet num = 5;
console.log(num.toExponential());

The code execution result:

javascript5e+0

Example

In this example, the exponential notation of the number 5 with 3 decimal places was output:

javascriptlet num = 5;
console.log(num.toExponential(3));

The code execution result:

javascript5.000e+0