Mechanism to provide number grouping in numeric literals

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Mechanism to provide number grouping in numeric literals

Biju Gm@il
When I want to write code to put timeout for 3 seconds, I prefer to write.

setTimeout(afunction, 3 * 1000);

This to avoid accidentally putting 30000 (or 300).
I wish there was mechanism to provide number grouping in numeric literals.

Java and C# come up with a underscore format.
http://docs.oracle.com/javase/7/docs/technotes/guides/language/underscores-literals.html
https://msdn.microsoft.com/en-us/magazine/dn683793.aspx (see:
Additional Numeric Literal Formats)

Is there an plan/proposal for number grouping in JavaScript?

Cheers
GC
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Mechanism to provide number grouping in numeric literals

Jordan Harband
Typically for setTimeout I use exponential notation to denote seconds, or when there's lots of zeroes - ie, `1e3` means "1000 ms" or "1 s". eg for 300,000, I'd do 300e3, or for 30,000,000 I'd do 30e6.

On Sat, Mar 14, 2015 at 8:51 PM, Biju <[hidden email]> wrote:
When I want to write code to put timeout for 3 seconds, I prefer to write.

setTimeout(afunction, 3 * 1000);

This to avoid accidentally putting 30000 (or 300).
I wish there was mechanism to provide number grouping in numeric literals.

Java and C# come up with a underscore format.
http://docs.oracle.com/javase/7/docs/technotes/guides/language/underscores-literals.html
https://msdn.microsoft.com/en-us/magazine/dn683793.aspx (see:
Additional Numeric Literal Formats)

Is there an plan/proposal for number grouping in JavaScript?

Cheers
GC
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss