I'm dealing with similar code in a project:
var groupedObject = {};
groupedObject['2016'] = {};
groupedObject['2022'] = {};
groupedObject['2014'] = {};
groupedObject['2021'] = {};
console.log(groupedObject);
No matter the order in which object values are created, the ALWAYS log returns the object in ascending order
Output:
2014:{}
2016:{}
2021:{}
2022:{}
I do not want this behavior. Could anyone explain why? How do I return the object in the order it is being created?