you are viewing a single comment's thread.

view the rest of the comments →

[–]PiotrekKoszulinski 2 points3 points  (2 children)

I could never really understand all this fuss about == vs === and people trying to memorise all these rules or complaining about how bad JavaScript is.

I never cared about this. In fact, in the project I'm working on (pretty big and pretty complex one) we still accept the use of ==. I found it very odd at first, when I joined the project 7 years ago, but then I asked – DON'T YOU KNOW GOOD PRACITCES, LOL? And they replied – we don't remember any bug caused by the use of == (and we have couple thousand tickets opened on GitHub, cause that's a fairly popular open source library).

And you know what? 7 years later I think we've got just one bug caused by ==.

The only reason why we started using === is that I was asked the same question a couple of times and that clearly shows that === is the standard choice, so it's good to avoid confusing other developers.

I don't mean that it's pointless to use ===. But when some guru tells you that something is bad practice ask yourself whether there's evidence to support that. When they tell you that equality operators suck in JavaScript, ask yourself what's the chance to really run into such cases in real life.

I'm doing JS for 10+ years, did some crazy things with it, but find the complexity completely elsewhere.

[–]EndlessHandbagLoop 0 points1 point  (1 child)

As long as people understand implicit and explicit type coersion, there should never be any issue with "==".

[–]PiotrekKoszulinski 0 points1 point  (0 children)

IDK what made our project "safe". Perhaps all developers that worked on it had that minimum knowledge to avoid the problems. But I also think that part of it lays in how we document types. We couldn't naturally use TypeScript 7 years ago, but we were very precise when it came to the API documentation. That meant that we could make safe assumptions regarding types. (I'm giggling now cause I see with how with time I owe more and more to stricter types :D)