Hacker News new | past | comments | ask | show | jobs | submit login

It’s a well known rule in JavaScript to default to “===“ for everything except checking for null or undefined, in which case “== null” is acceptable.

https://eslint.org/docs/rules/eqeqeq#smart

Even better is to just use TypeScript.




Does typescript really protect one from javascript though?

I imagine it is fine. If it was just myself developing I would be fine, but the insufferable junior devs that learned "=== or die" rear their ugly heads.


Checking for 'null or undefined' is an antipattern anyway, so there's no real valid use of '=='.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: