Type safeness and JavaScript

Content:

Original link: Yes, true + true === 2. And No, JavaScript Isn’t Broken / Dev.

I think there are two sets of questions and answers.

Yes - it is bad that you can use + on booleans. A good language is type safe enough to disallow that.

No - that problem is not unique for JavaScript - there are are many other languages that allow numeric operations on boolean (the article mention C/C++ and Python, but PHP also allows it).

Comments: