Sometimes, we want to parse and convert exponential values to decimal in JavaScript.
In this article, we’ll look at how to parse and convert exponential values to decimal in JavaScript.
How to parse and convert exponential values to decimal in JavaScript?
To parse and convert exponential values to decimal in JavaScript, we can use the toFixed
method.
For instance, we write:
const n = (4.656657507739E-10).toFixed(20)
console.log(n)
to call toFixed
on 4.656657507739E-10 and return a number with 20 decimal places.
Therefore, n
is 0.00000000046566575077.
toFixed
can parse numbers that has up to 20 decimal places.
Conclusion
To parse and convert exponential values to decimal in JavaScript, we can use the toFixed
method.