Wednesday, January 28, 2026
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

2 COMMENTS

Most Popular

Dominic
32475 POSTS0 COMMENTS
Milvus
122 POSTS0 COMMENTS
Nango Kala
6848 POSTS0 COMMENTS
Nicole Veronica
11978 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12065 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7221 POSTS0 COMMENTS
Thapelo Manthata
6934 POSTS0 COMMENTS
Umr Jansen
6915 POSTS0 COMMENTS