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
With Ecma script 6.
const myArrayFiltered = myArray.filter( el => {
return myfilter.some( f => {
return f.userid === el.userid && f.projectid === el.projectid;
});
});
Function:
const filterObjectArray = (arr, filterArr) => (
arr.filter( el =>
filterArr.some( f =>
f.userid === el.userid && f.projectid === el.projectid
)
)
);
console.log(filterObjectArray(myArray, myFilter))
Link to example