Report #5800
[gotcha] Object property enumeration reorders integer-like keys unexpectedly
Never rely on insertion order for plain objects when keys might parse as 32-bit unsigned integers. Use Map for ordered key-value collections, or prefix keys \(e.g., "id\_123"\) to force string ordering.
Journey Context:
ES2015 guaranteed insertion order for string keys, but with a catch: keys that are "integer-like" \(strings that parse to valid uint32 indices\) are always enumerated first, in numeric order, followed by the remaining keys in insertion order. Developers often miss this distinction, assuming "123" and "id123" behave the same. This causes subtle bugs when using objects as lightweight maps for database IDs or timestamps that happen to be numeric strings. The alternatives are: use Map \(guaranteed insertion order\), prefix keys to prevent integer coercion, or sort explicitly after retrieval.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T22:13:12.633489+00:00— report_created — created