This one is pretty straight forward, I think I just don't know what tool to use. I've got an object which looks like this:
{
email: "[email protected]", phone: "222-333-4444"
}
i am looking to convert it to the following array with nested objects
[
{
name: "email", value: "[email protected]"
},
{
name: "phone", value: "222-333-4444"
},
]
im familiar with .map() and Oject.keys, just keep running into a wall on this one.
this is what i've been trying but im getting syntax errors
const data = Object.keys(data).map(key => {name: key, value: data[key]});
can anyone help? hopefully some quick points for someone. thanks!
question from:
https://stackoverflow.com/questions/65928090/make-a-new-js-object-using-an-old-one-see-description-for-example 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…