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]})

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e48664-43c28.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e48664-43c28.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?