Friday, September 26, 2025
HomeLanguagesJavascriptLodash _.omitBy() Method

Lodash _.omitBy() Method

Lodash _.omitBy() method is used to return a copy of the object composed of the own and inherited enumerable string keyed properties of the object that the predicate doesn’t return truthy for. It is the opposite of _.pickBy() method.

Syntax:

_.omitBy( object, [predicate] );

Parameters:

  • object: This parameter holds the source object.
  • predicate: This parameter holds the function that is invoked for every property. It is an optional value.

Return Value:

This method returns the new object.

Example 1: In this example, we are omitting those values which do not support the _.isLength() method and returning the rest of the element as an object.

Javascript




// Requiring the lodash library 
const _ = require("lodash");
 
// The source object
let obj = {
    Name: "neveropen",
    password: 123456,
    username: "your_neveropen"
}
 
// Using the _.omitBy() method
console.log(_.omitBy(obj, _.isLength));


 Output: 

{Name: "neveropen", username: "your_neveropen"}

Example 2: In this example, we are omiting those values which do not support the _.isNumber() method and returning the rest of the element as an object.

Javascript




// Requiring the lodash library 
const _ = require("lodash");
 
// The source object
let obj = { 'x': 1, 'y': '2', 'z': 3 };
 
// Using the _.omitBy() method
console.log(_.omitBy(obj, _.isNumber));


 Output:

{'y': '2'}
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
32321 POSTS0 COMMENTS
Milvus
84 POSTS0 COMMENTS
Nango Kala
6690 POSTS0 COMMENTS
Nicole Veronica
11857 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11912 POSTS0 COMMENTS
Shaida Kate Naidoo
6802 POSTS0 COMMENTS
Ted Musemwa
7073 POSTS0 COMMENTS
Thapelo Manthata
6761 POSTS0 COMMENTS
Umr Jansen
6768 POSTS0 COMMENTS