Finding order in object properties
October 24, 2020
Even though in the past the lack of order may have been true, browsers actually were treating objects the same way. When that was discovered, a standard was set and all modern browsers now follow it.
The order the property keys take is as follows:
Numbers (otherwise known as integer indices, think like what an Array may have), these are sorted numerically.
Note: it can even be a string like ‘1’, the term integer indices means it can be converted between string and number and retain the same value.
Normal String keys. These are your typical
barkeys. They’ll appear in the order they’re added.
Symbol‘s. These come last, in the order they’re added.
Inner ramblings of Jason Adam.
Follow me on Twitter