<body>
<p>The toExponential() method returns a string, with the number rounded and written using exponential notation. An optional parameter defines the number of digits behind the decimal point.</p>
<p id="demo"></p>
<script>
var x = 9.656;
document.getElementById("demo").innerHTML =
x.toExponential() + "<br />" +
// returns 9.656e+0
x.toExponential(2) + "<br />" +
// returns 9.66e+0
x.toExponential(4) + "<br />" +
// returns 9.6560e+0
x.toExponential(6);
// returns 9.656000e+0 </script>
</body>
|
The toExponential() method returns a string, with the number rounded and written using exponential notation. An optional parameter defines the number of digits behind the decimal point.
|