Open In App

Lodash _.conformsTo() Method

Last Updated : 03 Nov, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Lodash _.conformsTo() method is used to check if the given object conforms to the given source by invoking the predicate properties of the source with the corresponding property values of the object. It returns true if it conforms, else false.

Syntax:

_.conformsTo( object, source );

Parameters:

  • object: This parameter holds the object to inspect.
  • source: This parameter holds the object of property predicates to conform to.

Return Value:

This method returns true if the object conforms, else false.

Example 1: In this example, we are checking whether the given condition is satisfying to the given object or not and printing the result in the console.

Javascript




// Defining Lodash variable
const _ = require('lodash');
 
// Initializing a object
let object = { 'gfg': 5, 'GFG': 10 };
 
// Calling the _.conformsTo() functions
_.conformsTo(object,
    {
        'gfg': function (n) { return n > 1; }
    }
);


Output:

true

Example 2: In this example, we are checking whether the given condition is satisfying to the given object or not and printing the result in the console.

Javascript




// Defining Lodash variable
const _ = require('lodash');
 
// Initializing a object
let object = { 'gfg': 5, 'GFG': 10 };
 
// Calling the _.conformsTo() functions
_.conformsTo(object,
    {
        'GFG': function (n) { return n > 12; }
    }
);


Output:

false


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads