Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

JS Puzzles · Const

Numeric Separators

Numeric separators are underscores placed between digits in a number literal, such as 1_000_000. They improve readability while leaving the represented numeric value unchanged.

How it works

Numeric separators let you place underscores between digits in numeric literals. JavaScript ignores those underscores when evaluating the literal, so the value is unchanged; they are only syntactic sugar for readability.

Syntax

number_literal_with_underscores

Key points

  • An underscore can separate digit groups in a numeric literal.
  • The syntax works directly in ordinary decimal literals.
  • The separator is syntactic sugar intended to make source code easier to read.
  • Grouping digits visually helps readers recognize large quantities.

Common mistakes

  • Separators affect source readability only; they do not change the numeric value.

Example: Readable numeric literals

const billion = 1_000_000_000;
const hex = 0xFF_FF;

console.log(billion === 1000000000); // true
console.log(hex === 65535); // true

Underscores make digit groups easier to read while preserving the numeric value.

When to use it

Readable large constants

Writing large constants such as limits, byte counts, or monetary values in source code.

Grouped non-decimal literals

Representing hexadecimal, binary, or other supported numeric literals with grouped digits.

Interview questions

QWhat are numeric separators in JavaScript?

Numeric separators are underscores inserted between digits of a numeric literal, such as 1_000_000. The engine ignores them, so the literal has the same value as 1000000.

Follow-up: Can a separator be used outside a numeric literal? No; this feature is syntax for numeric literals, not a general number-formatting operation.

QWhy use numeric separators?

They improve the readability of large numeric literals without requiring string conversion or runtime formatting. For example, 1_000_000 clearly groups the digits while remaining a number.

Follow-up: How would you display locale-specific grouping instead? Use number-formatting APIs such as Intl.NumberFormat rather than source-level separators.

QHow is a numeric separator written?

The separator is written as an underscore between digits, as in 1_000_000_000. It is part of the literal’s source syntax and is removed conceptually when the value is interpreted.

Follow-up: What value does 1_000_000_000 produce? It produces the same number as 1000000000.

  • Number literals
  • Decimal numbers
  • Hexadecimal numbers
  • Binary numbers
  • Octal numbers

Source: Numbers - The Modern JavaScript Tutorial. Checked 2026-10-15.