VOOZH about

URL: https://www.geeksforgeeks.org/javascript/lodash-_-omit-method/

⇱ Lodash _.omit() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Lodash _.omit() Method

Last Updated : 24 Sep, 2024

Lodash _.omit() method is used to return a copy of the object that is composed of the own and inherited enumerable property paths of the given object that are not omitted. It is the opposite of the _.pick() method.

Note: The _.omit() method is slower than the _.pick() method.

Syntax:

_.omit(object, [paths])

Parameters:

  • object (Object) parameter holds the source object.
  • paths (…(string|string[])) parameter holds the property paths to omit.

Return value:

This method returns the new object.

Example 1: In this example, we have omitted the 'name' and 'username' by using the _.omit() method by passing the path.

Output:

 {password: "gfg@1234"}

Example 2:   In this example, we have omitted the 'x' and 'y' by using the _.omit() method by passing the path.

Output:

{'z': 3}
Comment