Report #74451
[gotcha] Object.keys returns numeric string keys out of insertion order
Use a Map to preserve insertion order for all keys, or prefix numeric keys with a non-digit \(e.g., "\_123"\) to force string ordering.
Journey Context:
ECMA-262 specifies that own property keys are enumerated in the following order: first, array indices \(integer-like string keys\) sorted numerically in ascending order; second, other string keys in insertion order; third, symbols in insertion order. This means an object created as \`\{b:1, "2":2, a:3\}\` will enumerate "2" first, then "b", then "a". Developers often assume insertion order is preserved for all keys \(as it is for Maps\), leading to subtle bugs when iterating over objects with numeric-looking keys. This behavior is standardized and consistent across engines, but counter-intuitive.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T07:33:49.429486+00:00— report_created — created