Wednesday, October 8, 2025
HomeLanguagesJavascriptLodash _.isMatch() Method

Lodash _.isMatch() Method

The 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: This method accepts two parameters as mentioned above and described below:

  • object: Object in which source is to be matched.
  • source: Source which is to be matched.

Return Value: This method returns a Boolean value(Returns true if the source and the given object match, else false).

Example 1: 

Javascript




// Defining Lodash variable 
const _ = require('lodash'); 
  
var object = { 'Geeks': "GfG", 'Geeks2': "GfG2" };
  
// Checking
console.log(_.isMatch(object, { 'Geeks2': "GfG2" })); 
  
// Checking
console.log(_.isMatch(object, { 'Geeks': "GfG2" }));


Output:

true
false

Example 2: For checking with an empty source this method returns true.

Javascript




// Defining Lodash variable 
const _ = require('lodash'); 
  
var object = { 'Geeks': "GfG", 'Geeks2': "GfG2" };
  
// Checking
console.log(_.isMatch(object, { }));


Output:

true

Example 3: This method also works for arrays.

Javascript




// Defining Lodash variable 
const _ = require('lodash'); 
  
var object = [1, 2, 3];
  
// Checking
console.log(_.isMatch(object, [1, 2])); 
  
// Checking
console.log(_.isMatch(object, [1, 3]));


Output:

true
false
RELATED ARTICLES

Most Popular

Dominic
32342 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6712 POSTS0 COMMENTS
Nicole Veronica
11875 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11937 POSTS0 COMMENTS
Shaida Kate Naidoo
6833 POSTS0 COMMENTS
Ted Musemwa
7092 POSTS0 COMMENTS
Thapelo Manthata
6786 POSTS0 COMMENTS
Umr Jansen
6789 POSTS0 COMMENTS