在这里,我在这个arrayData中有arrayData数组对象。我有多个对象,我想从该数组对象中删除索引并键入键值。如何从此arrayData中删除?
arrayData : [
0: {
index: 0
is_required: true
name: "vmvdnksl"
type: "LONG_TEXT"
}
1: {
index: 1
is_required: true
name: "dsvnlk"
type: "MULTIPLE_SELECTORS"
}
]
删除索引和类型后,我想要这种类型的结果
arrayData : [
0: {
is_required: true
name: "vmvdnksl"
}
1: {
is_required: true
name: "dsvnlk"
}
]
最佳答案
const arrayData= [{index: 0,is_required: true,name: "vmvdnksl",type: "LONG_TEXT"},{index: 1,is_required: true,name: "dsvnlk",type: "MULTIPLE_SELECTORS"}];
const result = arrayData.map(({type,index,...rest}) => ({...rest}));
console.log(result);