Javascript - maintain key order when going from object -> array

后端 未结 3 676
时光说笑
时光说笑 2021-01-14 08:08

I know key order isn\'t guaranteed in JS objects, however, my data structure comes from a backend for which I have no control over. Is there anything I can do to preserve th

3条回答
  •  隐瞒了意图╮
    2021-01-14 08:18

    No. As you wrote:

    I know key order isn't guaranteed in JS objects

    If you want the order you need to use an array. If you have an object, then there is no defined order to the properties.

提交回复
热议问题