How to prevent sorting of the object by adding new properties to it?

How to prevent sorting of the object by adding new properties to it? The keys are integers. And if there was some kind of key 10 when the key is added 5 he stands in front of him. How can it be prevented?
April 3rd 20 at 18:29
2 answers
April 3rd 20 at 18:31
any way, the order of the keys in the object in General is not guaranteed, depends on the implementation in the engine, and tomorrow 5 could recite added after 10 and 10 to get up before 5. or suddenly your code will run on a v8 and not some other engine where it is not so.

Want guaranteed to iterate over keys in the order they were added - use an array or something else suitable.
April 3rd 20 at 18:33
https://developer.mozilla.org/ru/docs/Web/JavaScri...

The Map object contains key and value and stores the insertion order.
Any value (both objects and primitives) can be used as keys.

Find more questions by tags JavaScript