In JavaScript, how can an object or row be deleted from another object that contains it given the first?
var apple = { 'color': 'red', 'price': 100, 'origin': 'Japan' };
var fruits = { Object, Object, Object }; // objects: apple, orange, mango
delete fruits[apple]; // this does not work
The 'delete fruits[apple]' or it's other forms as explained in this SO thread are not working.
Is removing an 'object1' from an 'object2' possible by just providing 'object1' as a parameter as indicated before?
The method indicated in Deleting a row from javascript object:
var newFruits = fruits.filter(function( apple ) {
return fruits.color != apple.color &&
fruits.price != apple.price &&
fruits.origin != apple.origin;
});
Does not work either.
Edit
The fruits
just contains rows of { 'color', 'price' , 'origin' }
hence the last method. I actually need to compare these three components from a new array that might be inside the fruits
array.