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

Grouping and Notation Options

Enable or disable digit grouping and choose notations like standard, scientific, or compact.

Grouping and Notation Options

You'll learn how to control whether thousands separators appear in formatted numbers and how to switch between standard, scientific, and compact notations in Intl.NumberFormat.

What Are Grouping and Notation?

When formatting numbers, you often want control over two visual aspects:

  1. Grouping: Should large numbers display separators? (1000000 vs 1,000,000)
  2. Notation: How should the number be represented? (1000000 vs 1M vs 1E6)

The Intl.NumberFormat API lets you configure both through options when creating your formatter.

Disabling Digit Grouping

By default, most locales group digits with commas or spaces. You can disable this with useGrouping: false:

const withGrouping = new Intl.NumberFormat('en-US');
console.log(withGrouping.format(5000000)); // "5,000,000"

const withoutGrouping = new Intl.NumberFormat('en-US', { useGrouping: false });
console.log(withoutGrouping.format(5000000)); // "5000000"

Choosing a Notation

The notation option controls how numbers are displayed:

const standard = new Intl.NumberFormat('en-US', { notation: 'standard' });
console.log(standard.format(1500000)); // "1,500,000"

const scientific = new Intl.NumberFormat('en-US', { notation: 'scientific' });
console.log(scientific.format(1500000)); // "1.5E6"

const compact = new Intl.NumberFormat('en-US', { notation: 'compact' });
console.log(compact.format(1500000)); // "1.5M"

Compact notation is perfect for dashboards and social media (showing "2.4K likes" instead of "2,400 likes"). Scientific notation is useful for extremely large or small numbers in technical contexts.

Key Takeaway: Use useGrouping: false to remove thousands separators, and set notation to 'standard', 'scientific', or 'compact' to control how your numbers are represented for readability in different contexts.