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).
backend ruleP2universalStack: javascript
readabilityarraysdata-modeling
Build an object fully then push it once instead of mutating by index
Construct an object completely and append it to the array in one step rather than repeatedly assigning into array[0].
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codejavascript
| 1 | orderLines[0] = {}; |
| 2 | orderLines[0].id = id; |
| 3 | orderLines[0].qty = qty; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | const orderLine = { id, qty }; |
| 2 | orderLines.push(orderLine); |
Explanation (EN)
Objašnjenje (HR)