r/programming • • Mar 26 '14

JavaScript Equality Table

http://dorey.github.io/JavaScript-Equality-Table/
809 Upvotes

331 comments sorted by

View all comments

Show parent comments

-2

u/[deleted] Mar 26 '14

== is one of those easy targets for people who hate JavaScript's design.

In actual reality, == just isn't a problem. It can only cause bugs if your code is already poorly designed, and === exists.

8

u/Poltras Mar 26 '14

I would say that promoting bad behavior is the problem with JavaScript. Why have == at all?

1

u/[deleted] Mar 26 '14

JavaScript was designed to fill specific needs two decades ago. Type coercion was probably a useful addition for early use cases.

6

u/Poltras Mar 26 '14

That's why I'm a big proponent of a new browser language (be it Dart or something). JavaScript was made for constructs like onclick="this.className=(!this.className || 'clicked')". The fact that we are using it for applications now doesn't make it a good language by design, and "just use that instead of this" is a poor defense for fundamental flaws. And I'm not only talking about true vs truthy. Scope, context and this also comes to mind.

→ More replies (6)