I am looking a way to delete all elements from array if target object attribute is present in array.
var msg={name:'tar', type:'SR'}; //want to delete all object with type=SR
var items= [{name:'oh', type:'SR'},{name:'em', type:'PR'},
{name:'ge', type:'MR'},{name:'ohoo', type:'SR'}];
items.splice( items.indexOf(msg.type), 1 );
In this way only one object is deleting. Can someone suggest a better way that without using a loop i can delete all the target object from array
items.indexOf(msg.type)return-1asindexOflook for the value"SR"