Lodash - isMatch method


Advertisements

Syntax

_.isMatch(object, source)

Performs a partial deep comparison between object and source to determine if object contains equivalent property values.

Arguments

  • object (Object) − The value to inspect.

  • source (Object) − The object of property values to match.

Output

  • (boolean) − Returns true if object is a match, else false.

Example

var _ = require('lodash');
var object = { 'a': 1, 'b': 2 };
 
console.log(_.isMatch(object, { 'b': 2 }));
console.log(_.isMatch(object, { 'b': 1 }));

Save the above program in tester.js. Run the following command to execute this program.

Command

\>node tester.js

Output

true
false
lodash_lang.htm
Advertisements