Last Updated : 04 Sep, 2024
Lodash _.isMatchWith() method performs a partial deep comparison between object and source to determine if the object contains equivalent property values. Due to partial comparisons, it will match empty array and empty object source values against any array or object value, respectively. This method accepts another function as “customizer” which is invoked to compare values.
Syntax:_.isMatchWith( object, source, [customizer] )Parameters:
Example 1: In this example, we are checking whether the given value matches the object or not.
JavaScript
// Defining Lodash variable
const _ = require('lodash');
let object = { 'Geeks': "GfG", 'Geeks2': "GfG2" };
function fun() {
return true;
}
// Checking
console.log(_.isMatch(object, { 'Geeks2': "GfG2" }, fun));
// Checking
console.log(_.isMatch(object, { 'Geeks': "GfG2" }, fun));
Output:
true
false
Example 2: In this example, for checking with an empty source this method returns true.
JavaScript
// Defining Lodash variable
const _ = require('lodash');
let object = { 'Geeks': "GfG", 'Geeks2': "GfG2" };
function fun() {
return true;
}
// Checking
console.log(_.isMatch(object, {}, fun));
Output:
true
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4