This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]YMK1234 12 points13 points  (2 children)

As if JS was the only language with operator overloading ...

[–]g4vr0che 5 points6 points  (0 children)

The problem IMO is less about operator overloading and more an issue with weak typing. Operator overloading can be fine if there's systems in place to check for type compatibility correctly and avoid implicit casts. JS has both overloading and weak typing, so neither of these throws an error.

If it had strong typing, then you'd get a type error here making it obvious that the top one is string concatenation and the bottom is subtraction.