Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
fullstack ruleP1universalStack: javascript
correctnessequalitytypesclean-code
Compare values of the same type rather than relying on loose equality
When comparing two values, cast both to the same type (string or number) so a strict comparison is meaningful.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | if (ticker.milistreamId === req.query.id) { /* number === string is always false */ } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | if (String(ticker.milistreamId) === String(req.query.id)) { /* compared as same type */ } |
Explanation (EN)
Objašnjenje (HR)