Thousand separator in numeric type literals

Axel Rauschmayer axel at
Mon Apr 30 08:55:38 PDT 2012


Java has started to allow the underscore in numeric literals. JavaScript should do the same. For binary numbers, you’ll usually prefer groups of four. For hex numbers, probably, too. That’s why one should not restrict (much) where the underscore is allowed.

On Apr 30, 2012, at 9:14 , Biju wrote:

> One of the issue in most programming languages is, they dont have a
> mechanism to insert Thousand separators in numeric literals.
> Recently, at work I have fixed a production bug by adding extra "0" in
> a numeric literal in a JS code on a page.
> Since long I wish there are is a mechanism to represent Thousand
> separator in Java Script numeric literals, to make code more readable.
> I see the use of underscore to do this in Ruby
> Can we have a similar feature in JavaScript.
> By adding a Thousand separator in the code will reduce a great number
> of such errors.
> Sample
> 123_456                   # Fixnum (underscore ignored)
> 123_456_789_123_345_789   # Bignum
> -0b101_010                # Binary (negated)
> Cheers
> Biju
> _______________________________________________
> es-discuss mailing list
> es-discuss at

Dr. Axel Rauschmayer
axel at


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list