That’s not even true though. If I write false+[], that returns ”false”. But if I write false***[], that’s a parse error.
So I can write programs that “crash” in JavaScript - the question more is, why doesn’t false+[] do the saner thing of just throwing an error/exception? JavaScript’s rule of coercing any operand involved with addition to a String UNLESS every operand is a number doesn’t really make much sense at all…
View all comments
Show parent comment
6
u/ArtOfWarfare Mar 21 '24
That’s not even true though. If I write
false+[], that returns”false”. But if I writefalse***[], that’s a parse error.So I can write programs that “crash” in JavaScript - the question more is, why doesn’t
false+[]do the saner thing of just throwing an error/exception? JavaScript’s rule of coercing any operand involved with addition to a String UNLESS every operand is a number doesn’t really make much sense at all…