But, like, that happened *despite* JS being a terrible language. It's a consequence of its popularity; JS isn't popular because it's a good language, it's popular because it happened to wind up being *the* language of the web (and people are trying to use it for other things).
Ultimately this is a problem of the principle of least surprise. To any reasonable human, a string of digits with no decimal point is an *integer*. However, to JavaScript, it's a *float*. JS is abusing this point to produce unexpected results from toString.
-
-
Yes, the output string equals the float when spat back into a JS interpreter, but that's besides the point. It's not what a *human* expects. This is like the people complaining about things like undefined behavior in C. Except the latter is at least often useful for performance.
-
This stuff hurts people trying to learn the language, because instead of doing what's natural and obvious, things will work until suddenly they don't. The person learning will be bit by bugs, and will be told "that's just the way it is", but it shouldn't *be* that way.
- Show replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.