Saturday, November 15, 2025
HomeLanguagesJavascriptLodash _.conforms() Method

Lodash _.conforms() Method

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

The _.conforms() method of Util is used to create a function that calls the predicate properties of the source with the analogous property values of a stated object, which returns true if all the predicates are true else returns false.

Syntax:

_.conforms(source)

Parameters: This method accepts single parameter as described below:

  • source (Object): It is the object of property predicates which is to be conform.

Return Value: This method returns the new specified function.

Example 1:




// Requiring the lodash library
const _ = require('lodash');
  
// Initializing an object
var object = [
  { 'x': 2, 'y': 3 },
  { 'x': 5, 'y': 6 }
];
  
// Calling _.conforms() function with its parameter
let newfunc = _.filter(object, _.conforms({ 'y': function(n) { 
return n > 3; } }));
  
// Displays output
console.log(newfunc);


Output:

[ { x: 5, y: 6 } ]

Example 2:  




// Requiring the lodash library
const _ = require('lodash');
  
// Initializing an object
var object = [
  { 'GfG': 13, 'neveropen': 5 },
  { 'GfG': 7, 'neveropen': 4 }
];
  
// Calling _.conforms() function with its parameter
let newfunc = _.filter(object, _.conforms({ 'GfG': function(n) { 
return n > 13; } }));
  
// Displays output
console.log(newfunc);


Output:

[]

Here, nothing is returned as the stated condition is not satisfied.

Reference: https://lodash.com/docs/4.17.15#conforms

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
32399 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6765 POSTS0 COMMENTS
Nicole Veronica
11917 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11984 POSTS0 COMMENTS
Shaida Kate Naidoo
6890 POSTS0 COMMENTS
Ted Musemwa
7143 POSTS0 COMMENTS
Thapelo Manthata
6838 POSTS0 COMMENTS
Umr Jansen
6840 POSTS0 COMMENTS