Creates a function that performs a deep comparison between a given target and the source object.
The source object to create the matcher from.
true
false
// Basic usageconst matcher = matches({ a: 1, b: 2 });matcher({ a: 1, b: 2, c: 3 }); // truematcher({ a: 1, c: 3 }); // false Copy
// Basic usageconst matcher = matches({ a: 1, b: 2 });matcher({ a: 1, b: 2, c: 3 }); // truematcher({ a: 1, c: 3 }); // false
// Matching arraysconst arrayMatcher = matches([1, 2, 3]);arrayMatcher([1, 2, 3, 4]); // truearrayMatcher([4, 5, 6]); // false Copy
// Matching arraysconst arrayMatcher = matches([1, 2, 3]);arrayMatcher([1, 2, 3, 4]); // truearrayMatcher([4, 5, 6]); // false
// Matching objects with nested structuresconst nestedMatcher = matches({ a: { b: 2 } });nestedMatcher({ a: { b: 2, c: 3 } }); // truenestedMatcher({ a: { c: 3 } }); // false Copy
// Matching objects with nested structuresconst nestedMatcher = matches({ a: { b: 2 } });nestedMatcher({ a: { b: 2, c: 3 } }); // truenestedMatcher({ a: { c: 3 } }); // false
Alias