Formatting Numbers and Currency
Use Intl.NumberFormat for locale-aware numbers.
The Intl Namespace
Intl is the built-in JavaScript internationalization API. It formats numbers, dates, currencies, and more according to a locale's conventions — no library needed.
console.log(typeof Intl); // "object"
console.log(typeof Intl.NumberFormat); // "function"Intl.NumberFormat Basics
Create a formatter with a locale, then call format(). Locales use BCP 47 tags like "en-US" or "de-DE".
const nf = new Intl.NumberFormat("en-US");
console.log(nf.format(1234567.89)); // "1,234,567.89"All lessons in this course
- Formatting Numbers and Currency
- Formatting Dates and Times
- Relative Time and Plurals
- Locale-Aware Sorting