Report #52287
[gotcha] Object property iteration order moves numeric string keys to the front
Use Map for key-value collections with arbitrary keys; if using objects, prefix keys with a non-numeric character \(e.g., 'id\_' \+ key\) to preserve insertion order, or accept that '1', '2' will always appear before 'foo'.
Journey Context:
While ES2015 guaranteed insertion order for string keys, an exception remains: keys that parse as integer indices \(like '0', '1', '10'\) are sorted numerically and placed before non-numeric keys. This causes subtle bugs when using objects as dictionaries with user-generated IDs that might be numeric strings. Map avoids this entirely by treating all keys strictly by insertion order regardless of format.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:15:23.614523+00:00— report_created — created