Given a value of 1000.5, I want to format it as 1,000.50 USD (where the trailing currency code is the most relevant part). Performance is also important, as the formatting will be issued for millions of values. Hence, regex is discouraged.
Can you accomplish this using Intl.NumberFormat or some other standardized JavaScript number formatting API?
Example:
const formatter = Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', currencyDisplay: 'code' })
formatter.format(1000.5)
Actual:
USDÂ 1,000.50
Expected:
1,000.50 USD