Saturday, October 18, 2025
HomeLanguagesJavascriptLodash _.conformsTo() Method

Lodash _.conformsTo() Method

Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, collection, strings, objects, numbers etc.

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

  • 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:

Javascript




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


Output:

true

Example 2:

Javascript




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


Output:

false
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS