React - convert object into array of objects with properties

后端 未结 4 948
时光说笑
时光说笑 2021-01-25 07:15

I have the following object

\"data\":{  
         \"name 1\":\"a\",
          \"name 2\":\"b\",
          \"name 3\":\"b\",
        },

How can

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-25 07:41

    js native method u can use;

    var data = {  
         "name 1":"a",
          "name 2":"b",
          "name 3":"b",
        };
        var newObj = [...Object.values(data), ...Object.keys(data)]
        console.log(newObj)

提交回复
热议问题