我的目标是从对象中删除数组 [] 和一些属性。我可以通过方法从对象中删除一个属性delete,但是当我想删除多个属性时,它会显示如下错误The operand of a 'delete' operator must be optional.
Experience数组有一个对象,它可能有多个对象。
experience: [
{
organisation: "",
id: "",
from: "",
to: "",
skills: [],
achievements: 0,
},
{
organisationName: "",
id: "",
from: "",
to: "",
skills: [],
achievements: 0,
}
]
这是代码:
let skillsArray = this.state.experiences.map((item) => {
let newItem = { ...item }
delete newItem.skills;
delete newItem.achievements;
return newItem;
})
谁能帮我解决这个问题?
莫回无
烙印99
相关分类