r/ProgrammerHumor • • Mar 20 '24

Meme areJSDevsActuallySane

Post image
14k Upvotes

554 comments sorted by

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 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…

9

u/swishbothways Mar 21 '24

Tsk tsk. It didn't technically crash. It just didn't parse. Never said anything about a philosophy that code shouldn't ever not parse.

1

u/andouconfectionery Mar 21 '24

As far as your runtime's parser is concerned, what you wrote is no more similar to valid JS than this comment.