Thousand separator in numeric type literals

Biju bijumaillist at gmail.com
Mon Apr 30 00:14:46 PDT 2012


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
http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_stdtypes.html#S1
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


More information about the es-discuss mailing list