I have an Array of objects that looks like this but a little bigger:
var total = [{ cost="6.00", descrip="tuna"},{ cost="5.50", descrip="cod"}];
I need a way of deleting specific full objects from the array. Is it possible to identify the index of an object, based on the value of a property? The splice method looks like it could work if so.
total.splice(x,1);
Otherwise perhaps I could use the below in someway? can the objects in an array be given names and used with this somehow:
delete total[];
Not really sure what your problem is. You first have to find which item you want to remove:
The
findItem(total)function will return an index of an element matchingcost == '5.50'condition (of course you can use another one). Now you know what to do:I’m assuming there is at least one object in the array matching the condition.