Report #61186
[gotcha] Object key enumeration reorders numeric string keys unexpectedly
Use Map for insertion-sensitive key order; if using Object, prefix numeric keys with a non-digit \(e.g., 'id\_123'\) to prevent integer-index sorting
Journey Context:
ECMAScript spec \(OrdinaryOwnPropertyKeys\) mandates enumeration order: first array indices \(strings convertible to integers 0..2^32-2\) in ascending numeric order, then other string keys in insertion order, then symbols. Developers often assume Objects preserve insertion order for all keys, leading to subtle bugs when using numeric IDs as keys \(e.g., \{ '10': a, '2': b \} enumerates as '2' then '10'\). Using Map avoids this entirely; prefixing keys ensures they are not treated as array indices.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T09:11:02.729992+00:00— report_created — created