I'm trying to remove an item with a property from array object based on the key but it is leaving an empty object. For example,
var items = [{"fruits": ["Apple","Banana"]},{"veggies": ["Potato","Carrot"]}]
So I want to remove the item with the fruits property. This is the code I tried...
var filter = items.map(({ fruits, ...rest }) => rest);
This gave me an output of
[{},{"veggies": ["Potato", "Carrot"]}]
Why is it leaving a trace of an empty object? And how to get rid of that empty object?