This question is similar to this one Jquery filter array of object with loop but this time I need to do the filter with an array of objects.
Exemple:
I have
This code will match with not only by userid and projectid but with all properties of myFilter[j].
var filtered = myArray.filter(function(i){
return myFilter.some(function(j){
return !Object.keys(j).some(function(prop){
return i[prop] != j[prop];
});
});
});
console.log(filtered);
So you can use
myFilter = [
{
projectid: "11"
},
{
userid: "101"
},
{
userid: "103",
projectid: "13",
rowid: "3"
}
];
Will return
[ { userid: '101', projectid: '11', rowid: '1' },
{ userid: '103', projectid: '13', rowid: '3' },
{ userid: '101', projectid: '10', rowid: '4' } ]
Wich means all elements with
(projectid=="11")
OR (userid=="101")
OR ( (userid=="103") AND (projectid=="13") AND (rowid=="3") )