3
I’m dealing with a similar code in a project:
var groupedObject = {};
groupedObject['2016'] = {};
groupedObject['2022'] = {};
groupedObject['2014'] = {};
groupedObject['2021'] = {};
console.log(groupedObject);
No matter the order in which the object values are created, the log ALWAYS returns the object in ascending order
Output:
2014:{}
2016:{}
2021:{}
2022:{}
I don’t want this behavior. Could anyone explain why? How to return the object in the order it is being created?
have to use an array
– tomasantunes
@Tomásantunes, Unfortunately in my situation I need it to be an object. And I need you to respect the order in which it is being created
– Pablo Carvalho