1

For Object.entries, Why is the 0 index giving me item on index 1 ?

const object3 = { 100: 'a', 2: 'b', 7: 'c' };
console.log(Object.entries(object3)[0]);
// expected output: Array ["2", "b"]

Is there something with the random keys ?

ashfaq.p
  • 4,877
  • 15
  • 30
  • 1
    the keys, who could be indices of an array are sorted before other keys of the object. – Nina Scholz May 04 '18 at 17:36
  • Can you explain further ? – ashfaq.p May 04 '18 at 17:37
  • 2
    you may have a look here: https://stackoverflow.com/a/32149345/1447675 – Nina Scholz May 04 '18 at 17:40
  • I don't know if JS *sometimes* giving this guaranteed order according to a specific algorithm other than creation/insertion order was a good idea. There's certainly some benefit, yet the behavior can seem mysterious. –  May 04 '18 at 17:43

0 Answers0