Numeric Separators Split Long Literals
Underscore separators group digits inside numeric literals — decimal, binary, and floats included — without changing the value they denote.
Code
// 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.5001How 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
Number Base ConverterConvert arbitrary-size integers between binary, octal, decimal, hexadecimal, and base 36 with digit validation and signed input support.Number to WordsConvert an integer up to 999,999,999,999 into US English words, using the short scale and a minus prefix for negative values.Roman Numeral ConverterConvert integers between 1 and 3999 to Roman numerals and back, rejecting malformed numeral forms.Scientific Notation ConverterConvert numbers between plain decimal and scientific notation, optionally fixing the significant digits and splitting out the mantissa and exponent.
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`.
Report a problem with this exampleOpens a pre-filled issue on GitHub.