print object property as they were created not in ascending order

Viewed 10

I have read somewhere that integer properties are sorted, others appear in creation order. As an example...

let codes = {
  "4": "Learning",
  "2": "JS",
  "3": "is",
  // ..,
  "1": "Fun"
};

for (let code in codes) {
  console.log(code);
}

codes go in the ascending sorted order but what is the reason why that happened ? what if we try to print result as we created it, how many ways possible to create same as we created it.

0 Answers
Related