Last Updated : 04 Sep, 2024
Lodash _.isMatch() 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.
Syntax:_.isMatch(object, source);Parameters:
Example 1: In this example, we are checking whether the given value is present in the given object or not by the use of the lodash _.isMatch() method.
JavaScript
// Defining Lodash variable
const _ = require('lodash');
let object = { 'Geeks': "GfG", 'Geeks2': "GfG2" };
// Checking
console.log(_.isMatch(object, { 'Geeks2': "GfG2" }));
// Checking
console.log(_.isMatch(object, { 'Geeks': "GfG2" }));
Output:
true
false
Example 2: In this example, we are checking whether the given value is present in the given object or not by the use of the lodash _.isMatch() method. for empty object it will always return true.
JavaScript
// Defining Lodash variable
const _ = require('lodash');
let object = { 'Geeks': "GfG", 'Geeks2': "GfG2" };
// Checking
console.log(_.isMatch(object, {}));
Output:
true
Example 3: In this example, we are checking whether the given value is present in the given array or not by the use of the lodash _.isMatch() method.
JavaScript
// Defining Lodash variable
const _ = require('lodash');
let object = [1, 2, 3];
// Checking
console.log(_.isMatch(object, [1, 2]));
// Checking
console.log(_.isMatch(object, [1, 3]));
Output:
true
false
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