These days, if you need huge integers, you can use BigInt, but if you want to use it in an expression that also contains floating point values, then you need to explicitly convert it. Explicit is better than implicit.
These days, if you need huge integers, you can use BigInt, but if you want to use it in an expression that also contains floating point values, then you need to explicitly convert it. Explicit is better than implicit.
The expectation is that sorting an array of integers in place:
[1,3,2,4,5,7,6,8,9,10].sort()
produces an array with the numbers in ascending order (since that's what Ruby/Python do). Not so with JS (try it out).A agree there is a perfectly logical reason for every quirky behavior, but I've been surprised (in a bad way) so many times by JS's counter-intuitive behavior that I now have a mental collection of gotchas where JS deviates from expectation.
JavaScript actually has a formal specification. Ruby and Python have no formal specification. I can tell you (with reference to the specification) exactly what a JavaScript program does. JavaScript may seem wacky on the surface, but actually it's all worked out. Nobody can tell you what a Ruby or Python program does.
And you think JavaScript is the footgun?
"Theory is great in theory, but in practice, practice is better"
JS has many quirks, but I like that the numeric representation is extremely simple and explicit (even compared to Python).
[1,3,2,4,5,7,8,9,10].sort((a,b) => a - b) gives you the behavior one would expect.
I suppose you already know that, though. Agreed there are lots of quirks.