Does Object.keys keep your insert order in JavaScript?
Assign the keys b , 2 , a , 1 to a plain object and Object.keys comes back as 1, 2, b, a . That is not a bug and it is not random: the spec splits keys into two groups and sorts one of them. The test const o = { } ; o . b = 1 ; o [ 2 ] = 2 ; o . a = 3 ; o [ 1 ] = 4 ; console . log ( Object . keys (…
Read the full story at DEV Community — AI ↗
Timeline · 1 report
- 2026-12-06 00:39 · DEV Community — AI
Does Object.keys keep your insert order in JavaScript?