Preserving the Order in Arrays

The problem with iterating over objects is that the order of iteration can vary. We will use State Object Normalization to solve this.

Caveat #2 : Preservation of Order.

This is perhaps the number one reason people use arrays. Arrays preserve the order of their values.

You have to see an example to understand this.

const numbers = [0,3,1,6,89,5,7,9]

Whatever you do, fetching the value of numbers will always return the same array, with the order of the inputs unaltered.

How about an object? Try it out below.

Get hands-on with 1200+ tech skills courses.