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:
const dummyArray = [
{ "att1": "something", "att2": "something", /* … */, "att100": "something" },
{ "att1": "something", "att2": "something", /* … */, "att100": "something" },
// …
];
How can I filter, map, reduce the array, or use some other method to extract the desired 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?