r/programminghorror
•
u/Leonnee
•
Jun 12 '25
•
1
Javascript Javascript is filled with horror
2.4k
Upvotes
View all comments
Show parent comment
4
u/TorbenKoehn Jun 12 '25
It's not bad design. All alternatives are worse (including just throwing an error)
It's sorting by "best guess" and the "best guess" is forcing it into a string, since all values can do it in JS.
Why does everything need to throw errors? You see it sorts your 11 after your 1, you look it up, realize the mistake you made, make it never again.
If it would throw an error you'd look it up, too, so the work involved is exactly the same.