3 ms·
The link you provided to demonstrate the problem also gives you the solution: > Moral of the story: > > Always use 3 equals unless you have a good reason to u
by insin 11y ago
The link you provided to demonstrate the problem also gives you the solution:
> Moral of the story:
>
> Always use 3 equals unless you have a good reason to use 2.
Tools like ESLint make it easy to enforce this (and to only allow == in the few cases where those good reasons apply).
- trymas 11y agoI think we are getting into deep rant, though I want to say, that even I know this rule of JS (always use 3 equals, unless you know why you need 2) why not make double equal work as triple one?
- mkishi 11y agoIf we were to rewrite history, that'd probably happen. Now count the number of languages that wouldn't reconsider something if we were able to.. I understand your frustration with js, but let's not pretend it's objectively worse to learn to deal with its pitfalls instead of other languages'.
- untog 11y agoBecause JS makes a point of being backwards compatible. Which is great, because some people out there are still using IE6.