Bisexual Pride

Since ES2021 (ES12), you can make large numbers more readable in JavaScript by inserting underscores. Underscores inside numeric literals are called numeric separators.

Here are some examples:

const oneThousand = 1_000;
const tenThousand = 10_000;
const oneHundredThousand = 100_000;
const oneMillion = 1_000_000;
const tenMillion = 10_000_000;

The placement of the underscores is arbitrary; itโ€™s purely for readability. If you wrote 1_0_0, it would still be the value 100. This makes numeric separators nice for working with currencies:

// This is still 100 cents
const oneDollar = 1_00;

The MDN Web Docs state that there are a few limitations, though:

// More than one underscore in a row is not allowed
100__000; // SyntaxError

// Not allowed at the end of numeric literals
100_; // SyntaxError

// Cannot be used after leading 0
0_1; // SyntaxError

You can check the full browser support info on Can I Use.