I am trying to achieve the following task with lodash or pure JS.
I have an Array of Objects which I filter by a given property value
let res = _.filter(array, {obj.property: "somevalue"}
Now I have another Array like so [val1, val2,val3] which I want the filtered array properties to compare with like so.
let res = _.filter(array, {obj.property1: "somevalue", obj.property2: existsInOtherArray}
You can use a set and the filter method of array like:
const array = [
{property1: 'somevalue'},
{property1: 'somevalue', property2: 'val2'}
]
const set = new Set(['val1', 'val2', 'val3'])
const res = array.filter(obj => obj.property1 === 'somevalue'
&& set.has(obj.property2))
console.log(res)