Parameters or Arguments
fractionalDigits Optional. It is the quantity of fractional digits to show in the result. If this parameter is omitted, up to 16 fractional digits might also show up in the result, depending on your browser.
The toExponential() technique converts a wide variety to exponential notation and then returns its price as a string.
The toExponential() method does not change the cost of the original number.
var totn_number = 123.456789; console.log(totn_number.toExponential()); console.log(totn_number.toExponential(1)); console.log(totn_number.toExponential(2));
In this example, we have declared a variable known as totn_number that is assigned the price of 123.456789. We have then invoked the toExponential() method of the totn_number to convert the number to exponential notation represented as a string.
We have written the output of the toExponential() technique to the internet browser console log, for demonstration purposes, to exhibit what the toExponential() approach returns.
The following will be output to the web browser console log:
1.23456789e+2 1.2e+2 1.23e+2
In this example, the first output to the console log returned the string cost “1.23456789e+2” which is the exponential notation for the quantity 123.456789.
The 2nd output to the console log lower back the string price “1.2e+2” which is the exponential notation for the range 123.456789 with 1 fractional digit.
The third output to the console log again the string value “1.23e+2” which is the exponential notation for the range 123.456789 with two fractional digits.