In programming as a whole, long numbers can be tough to read. It takes a few seconds to figure out just how big this number is. Is it around one hundred thousand, one million, ten million, or something else?


But JavaScript, for once, has a trick to make things easier! We can add underscores to numbers that make them more readable without affecting the value.

let x = 1_234_567
let y = 1234567

console.log(x === y)
// true (hooray!)

The x and y variables are the same number, but x is easier to read.

But with great power comes great responsibility. Using them too much can bring the code's readability back to square one.

let x = 1_2_3_4_5_6_7
let y = 1234567
// Both are the same number
// and just as confusing

Plus, there's the requisite example of "JavaScript absurdity you should do for fun but never for work."

You're better off using JavaScript's "infinity value," which I wrote about before. Unless you want to use this to mess with a coworker on April Fools Day.