I have an array of objects with the same properties. Each object has around a hundred properties. I want to keep only a handful of them in a new array:
var dummyArray = [{ "att1": "something", "att2": "something", ..., "att100": "something"}, { "att1": "something", "att2": "something", ..., "att100": "something"}, ...];
How can I filter/map/reduce... and extract the interesting keys?
const newDummArray = dummyArray.map(function(item) {
delete item.att1;
delete item.att3;
delete item.att15;
// ... (long list)
return item;
});
how can I keep only att20
, att30
, att70
, att80
for each object and delete the rest?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…