Thousand separator in numeric type literals
# Axel Rauschmayer (13 years ago)
+1
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.
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 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)