How do js objects convert to arrays?

now the code is

const list = {
  { "": [
    {name: "", to: "/basic"},
    {name: "", to: "/reset"}
  ]},
  {"": [
    {name: "", to: "/consume-log"},
    {name: "", to: "/recharge-log"},
    {name: "", to: "/recharge"}
  ]}
}

how can I implement this code if I want to change it into the following code?

const list = [
  { "": [
    {name: "", to: "/basic"},
    {name: "", to: "/reset"}
  ]},
  {"": [
    {name: "", to: "/consume-log"},
    {name: "", to: "/recharge-log"},
    {name: "", to: "/recharge"}
  ]}
]
Apr.09,2021

there is something wrong with your first definition

this place must have at least one key
clipboard.png
by the way, js object rotation array, Baidu is easy to find, Baidu

before asking questions. Whether

is received or written by yourself. If you write it, you can change it yourself, if you accept it.


class array objects can be converted to arrays via Array.from, but now you need babel support


first of all, there is something wrong with your object format. If you want to convert it, traverse it first, then create a new array, and then push it directly to


.

Object.keys (list) .map (key = > ({[key]: list [key]}))

/ / then add the key attribute myself

Object.keys (list) .map (key = > ({title:key,list: list [key]})

Menu