4 ms·
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://e
by tlrobinson 5y ago
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 https://eslint.org/docs/rules/eqeqeq#smart
Even better is to just use TypeScript.
- BigJono 5y agoChecking for 'null or undefined' is an antipattern anyway, so there's no real valid use of '=='.
- flippinburgers 5y agoDoes 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.