const compare = r => l => (typeof l === "object" ? contains(r)(l) : l === r);
const contains = r => l =>
Object.keys(r).every(k => l.hasOwnProperty(k) && compare(r[k])(l[k]));
var list = [
{
name: "Alice",
address: {
zip: "10000"
}
},
{
name: "Bob",
address: {
zip: "20000"
}
},
{
name: "Charlie",
address: {
zip: "30000"
}
}
];
var filter = {
address: { zip: "10000" }
};
console.log(list.filter(contains(filter)));
// [{"name":"Alice","address":{"zip":"10000"}}]