Numeric Separators Split Long Literals

Underscore separators group digits inside numeric literals — decimal, binary, and floats included — without changing the value they denote.

JavascriptData Integrity

Code

javascriptsnippet
15 lines
// Underscores group digits inside numeric literals; they carry no value
const budget = 1_250_000;
const mask = 0b1010_0001;
const secondsPerDay = 86_400;

console.log('budget:', budget);
console.log('mask:', mask, mask.toString(2));
console.log('secondsPerDay:', secondsPerDay);

// Separators work inside decimal fractions too
const rate = 0.000_001;
console.log('rate:', rate);

// Allowed between digits on both sides of the decimal point
console.log('float parts:', 1_000.500_1);

Output

Captured from a sandboxed run of this snippet in the build pipeline.

budget: 1250000
mask: 161 10100001
secondsPerDay: 86400
rate: 0.000001
float parts: 1000.5001

How it works

Demo state sits in top-level bindings: budget, mask, secondsPerDay, rate.

What to watch for

  • The whole dependency story is the language version itself.

Putting it to use

The run emits 5 labeled sections — budget:, mask:, secondsPerDay:, rate:, float parts: — one per step.

The core lines of the flow

const secondsPerDay = 86_400;
const budget = 1_250_000;
const mask = 0b1010_0001;

Interactive Tools for This Topic

FAQ

Anything to download besides the language toolchain?
Nothing beyond the toolchain you already have for this language. Its state lives in module-level bindings: `budget`, `mask`, `secondsPerDay`.