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 ruleP2universalStack: javascript
performanceimmutabilityclean-coderedundancy
Do not clone an object before an operation that does not mutate it
Skip defensive clones (e.g. before reduce, find, map) when the subsequent operation is non-mutating and the clone serves no purpose.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codejavascript
| 1 | const copy = { ...channels }; |
| 2 | return Object.values(copy).reduce(toResult, []); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | return Object.values(channels).reduce(toResult, []); |
Explanation (EN)
Objašnjenje (HR)