What Does Underscore in a JavaScript Number Mean?

Use of underscores (_) in JavaScript number literals is meant to improve readability. This feature is known as numeric separators (which was introduced in ES12). It can be used like so:

// ES12+
const million = 1_000_000;

console.log(million); // 1000000
console.log(million === 1000000); // true

If you wish to deep-dive into the topic, then read the post about what numeric separators are in JavaScript.

This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.