Learn every JavaScript number formatting method you actually need — toFixed, toPrecision, toLocaleString, Intl.NumberFormat, Math utilities and the traps to avoid.
Numbers are everywhere in web apps — prices, scores, statistics, percentages, progress bars. But JavaScript stores all numbers as 64-bit floating point values, and raw floating point results look terrible to users.
This is what I mean:
console . log ( 0.1 + 0.2 ); // 0.30000000000000004
Enter fullscreen mode
Exit fullscreen mode
That is not a bug. That is how binary floating point math works. The fix is not to change how JavaScript stores numbers — it is to control how you display them.…