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
performanceloopsoptimization
Hoist loop-invariant computation out of the loop
Compute values that do not change between iterations once before the loop instead of recomputing them every pass.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codejavascript
| 1 | items.forEach((i) => { |
| 2 | const key = publication.charAt(0).toUpperCase() + publication.slice(1); |
| 3 | use(i, key); |
| 4 | }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | const key = publication.charAt(0).toUpperCase() + publication.slice(1); |
| 2 | items.forEach((i) => use(i, key)); |
Explanation (EN)
Objašnjenje (HR)