Report #26306
[gotcha] Why does JavaScript money calculation concatenation break after rounding?
Always wrap toFixed\(\) with Number\(\) or parseFloat\(\) when continuing math: Number\(\(0.1\+0.2\).toFixed\(2\)\) \+ 1. Never use toFixed output in string concatenation without explicit conversion.
Journey Context:
Developers assume toFixed\(\) returns a Number because it's a math operation. This causes silent bugs when adding currency values: \(1.005\).toFixed\(2\) \+ 5 becomes '1.015' not 6.01. The alternative is using integer cents \(BigInt or library\) for money, but if using toFixed for display, you must cast back to Number for further arithmetic. The spec explicitly defines toFixed as returning a String for formatting purposes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T22:33:23.682974+00:00— report_created — created