Suppose that instead of 5, there is a 55-bit integer.
Pretty sure ints are 32 bits. And if you did write a 55 bit integer as a literal, then no, it's not promotion anymore and yes, an error should be thrown.
In any case, JS promotes implicitly to string because it just does.
So it's totally arbitrary then. Seems like an awful design decision.
Most JavaScript implementations handle integers upto... 52 bits (?) as integers. 53 fits into a double without precision loss, IIRC. After that you start getting problems.
1
u/yizzlezwinkle Aug 26 '20
Pretty sure ints are 32 bits. And if you did write a 55 bit integer as a literal, then no, it's not promotion anymore and yes, an error should be thrown.
So it's totally arbitrary then. Seems like an awful design decision.