Integer Keys Cut The Line
luljs still worksNumber-like object keys always come first, in ascending order.
In 2026: Still works, and it surprises people who expect insertion order. Since ES2015 the language sorts integer-like keys ascending and puts them before the string keys, which keep insertion order. Insert gold, 3, silver, 1 and the keys come back as 1, 3, gold, silver. You cannot pin a numeric key in a chosen spot.
Where it came from: Since ES2015 own keys enumerate as integer indices ascending, then string keys in insertion order. Stefan Judis wrote a clear walkthrough. Stefan Judis ↗
<script>
var medals = {}; medals.gold = 1; medals[3] = 1; medals.silver = 1; medals[1] = 1;
document.write('<p>Inserted in order: <code>gold, 3, silver, 1</code>.</p>');
document.write('<p><code>Object.keys(medals)</code> is <b>' + JSON.stringify(Object.keys(medals)) + '</b></p>');
document.write('<p>Integer-like keys sort to the front, ascending; string keys keep insertion order.</p>');
</script>