Report #55407
[gotcha] Object property enumeration reorders integer-like keys numerically before string keys
Avoid relying on insertion order for object keys; use Map for guaranteed insertion order, or prefix numeric keys \(e.g., 'id\_001'\) to force string ordering
Journey Context:
ECMAScript spec mandates that integer indices \(0 <= i < 2^32-1\) are sorted numerically in ascending order first, followed by string keys in insertion order, then symbols. This means obj\['10'\] = 'a'; obj\['2'\] = 'b'; obj\['x'\] = 'c' enumerates as 2, 10, x. Leading zeros \('02'\) prevent numeric interpretation and force insertion order. This bites when using timestamps or IDs as keys. Alternatives: Use Map which preserves insertion order for all keys, or convert objects to arrays of entries sorted explicitly. Never assume object key order matches insertion for numeric-looking strings.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T23:29:27.088721+00:00— report_created — created