Lodash _.conformsTo() Method
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
const _ = require( 'lodash' );
let object = { 'gfg' : 5, 'GFG' : 10 };
_.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
const _ = require( 'lodash' );
let object = { 'gfg' : 5, 'GFG' : 10 };
_.conformsTo(object,
{
'GFG' : function (n) { return n > 12; }
}
);
|
Output:
false
Last Updated :
03 Nov, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...