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
javascriptobjectsiterationreadability
Use Object.entries to iterate keys and values together
When you need both the key and value of an object, iterate with Object.entries instead of looking up the value by key inside the loop.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | Object.keys(params).forEach((key) => { |
| 2 | build(key, params[key]); |
| 3 | }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | Object.entries(params).forEach(([key, value]) => { |
| 2 | build(key, value); |
| 3 | }); |
Explanation (EN)
Objašnjenje (HR)