Example 1 — Official: Filter by Partial Match
Keep objects whose listed keys match the source pattern.
var objects = [
{ 'a': 1, 'b': 2, 'c': 3 },
{ 'a': 4, 'b': 5, 'c': 6 }
];
_.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
// → [{ 'a': 4, 'b': 5, 'c': 6 }] How It Works
- Pattern. Source requires
a === 4andc === 6. - First row.
ais1→ fails. - Second row. Both keys match;
bis ignored. - Result. Only the second object remains.

