Course contentsShow
← JavaScript
Lesson 2207 of 2,72346. InternationalizationFree lesson

Common NumberFormat Patterns

See real-world examples: price displays, statistics, and localized dashboards.

Common NumberFormat Patterns

What you'll learn: How Intl.NumberFormat solves real-world formatting challenges in price displays, statistics, and localized dashboards.

Now that you've mastered NumberFormat's configuration options, let's see how they combine to handle everyday scenarios across applications.

Price Displays

E-commerce sites need consistent, locale-aware pricing:

// US storefront
const usdFormatter = new Intl.NumberFormat('en-US', {
  style: 'currency',
  currency: 'USD'
});

// European storefront
const eurFormatter = new Intl.NumberFormat('de-DE', {
  style: 'currency',
  currency: 'EUR'
});

console.log(usdFormatter.format(1299.99)); // "$1,299.99"
console.log(eurFormatter.format(1299.99)); // "1.299,99 €"

Notice how grouping separators and currency symbols automatically adjust per locale.

Statistics Dashboards

Analytics platforms often display percentages and abbreviated large numbers:

// Conversion rate
const percentFormatter = new Intl.NumberFormat('en-US', {
  style: 'percent',
  minimumFractionDigits: 2
});

// User count (millions)
const compactFormatter = new Intl.NumberFormat('en-US', {
  notation: 'compact',
  compactDisplay: 'short'
});

console.log(percentFormatter.format(0.1847)); // "18.47%"
console.log(compactFormatter.format(2450000)); // "2.5M"

Think of these patterns as templates—you create the formatter once, then reuse it across thousands of data points for consistent presentation.

Localized Admin Panels

Multi-region admin tools need unit formatting for metrics like file sizes or distances:

const sizeFormatter = new Intl.NumberFormat('en-US', {
  style: 'unit',
  unit: 'megabyte',
  unitDisplay: 'short'
});

console.log(sizeFormatter.format(487.3)); // "487.3 MB"

Key Takeaway: Real-world NumberFormat patterns—currency for pricing, percent/compact for statistics, and unit for measurements—provide consistent, locale-aware formatting across your entire application by configuring reusable formatter instances.