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
correctnessequalityarrays
Compare array/object contents, not references, for equality
Using === or identity comparison on arrays/objects only checks reference equality; compare lengths and elements (or use a deep/structural check) when you mean value equality.
PR: vinify-frontend · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codets
| 1 | if (selectedFilters === defaultFilters) { ... } // always false for distinct arrays |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | const sameLength = a.length === b.length; |
| 2 | if (sameLength && a.every((item, i) => item === b[i])) { ... } |
Explanation (EN)
Objašnjenje (HR)