What is the toExponential() method in JavaScript?
The toExponential() method in JavaScript converts a number into the exponential notation in string format. If the method is invoked on an object that is not a number, a TypeError occurs.
Syntax
The toExponential() method is declared as shown below:
Parameters
The toExponential() method takes a single optional parameter x.
-
If
xis not within the range 0-100, aRangeErroroccurs. -
If
xis not specified, the default value is the number of digits required to specify the number.
Return value
The toExponential() method returns a string that represents the number as an exponential notation.
Example
The following code shows the use of the toExponential() method in JavaScript:
//Example 1var num = 1.25;console.log(num.toExponential());//Example 2var num2 = 1.234567;console.log(num2.toExponential(3));
Free Resources
Copyright ©2026 Educative, Inc. All rights reserved