File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -323,6 +323,12 @@ This is a TypeScript implementation of the Package URL (purl) specification for
323323- ** Array destructuring ** : Use object notation for tuple access
324324 - ✅ CORRECT : ` { 0: key, 1: data } `
325325 - ❌ AVOID : ` [key, data] `
326+ - ** Array destructuring performance ** : For ` Object.entries() ` loops , use object destructuring for better V8 performance
327+ - ❌ SLOWER : ` for (const [key, value] of Object.entries(obj)) `
328+ - ✅ FASTER : ` for (const { 0: key, 1: value } of Object.entries(obj)) `
329+ - ** Rationale ** : Array destructuring requires iterator protocol (per ECMAScript spec ), while object destructuring directly accesses indexed properties
330+ - ** Reference ** : https :// stackoverflow.com/a/66321410 (V8 developer explanation)
331+ - ** Trade - off ** : This is a microbenchmark optimization - prioritize readability unless profiling shows this is a bottleneck
326332- ** Array checks ** : Use ` !array.length ` instead of ` array.length === 0 `
327333- ** Destructuring ** : Sort properties alphabetically in const declarations
328334
You can’t perform that action at this time.
0 commit comments