I have an array of objects that have many properties. I would like to be able to find the matching items, based on a filter object that only contains a subset of the arrays properties. For Example, i have a customer
let Customer = {
Name: "John Doe",
Age: 80,
Hair: "Red",
Gender: "Male",
};
And i have my search object:
let searchObject ={
Hair: "Red",
Gender: "Male"
}
I want to be able to find inside my array, all customers that match searchObject, without having to do:
this.array.filter(z=>z.Hair == searchObject.Hair && z.Gender == searchObject.Gender);
I would like for it to be when searchObject adds more properties, it automatically filters on those too