Numeric Separators

Large numeric literals are difficult for the human eye to parse quickly, especially when there are long digit repetitions. This is a new stage-4 proposal JavaScript language feature enables underscores (_, U+005F) as separators in numeric literals to improve readability.

This feature is designed to have no impact on the interpretation semantics of numeric literals: _ are to be ignored by interpreters and should have no effect. They are meant exclusively as a visual clue to aid development and have no runtime semantics.

It works for numeric literals (integer, bigint, floating-point), fractional, and exponent parts with following limitations:

- No leading or trailing separator.
- No multiple adjacent separator.
- No separator adjacent to leading 0.
- No separator adjacent to BigInt n suffix.
- No separator adjacent to decimal point.
- No separator adjacent to ExponentIndicator.
- No separator adjacent to 0b, 0B, 0o, 0O, 0x, 0X.

Following are valid examples:

// decimal literals
1_000_000_000

// bigint literals
1_000_000_000n

// binary literals
0b1010_0001

// hex literals
0xa0_b0_c0

// octal literals
0o2_2_5_6

// floating-point literals
101_475_938.38

// in fractional part
0.000_001

// in exponent part
1e10_000

Following are invalid examples:

// SyntaxError: not allowed at the end of numeric literals
1_000_000_
0b1010_0001_

// SyntaxError: No multiple adjacent separator
0b1010__0001

// SyntaxError: Can not be used after leading 0
0_11011