Friday, November 21, 2025
HomeLanguagesJavascriptUnderscore.js _.omit() Function

Underscore.js _.omit() Function

The _.omit() function is used to return a copy of the object that filtered to omit the blacklisted keys.

Syntax:

_.omit(object, *keys)

Parameters: This function accept two parameters as mentioned above and described below:

  • object: This parameter holds the value of an object.
  • keys: It is an optional parameter. It contains the key name that value need to be omitted.

Return Value: It returns a copy of the object that filtered to omit the blacklisted keys.

Example 1:




<!DOCTYPE html>
<html>
  
<head>
    <script type="text/javascript" src=
    </script>
</head>
  
<body>
    <script type="text/javascript">
  
        var info = {
            Company: 'neveropen',
            Address: 'Noida',
            Contact: '+91 9876543210'
        };
  
        console.log(_.omit(info, 'Company', 'Address'));
    </script>
</body>
  
</html>


Output:

Example 2:




<!DOCTYPE html>
<html>
  
<head>
    <script type="text/javascript" src=
    </script>
</head>
  
<body>
    <script type="text/javascript">
  
        var info = {
            key1: 10,
            key2: 20,
            key3: 30,
            key4: 40,
            key5: 50
        };
  
        console.log(_.omit(info, function (value, key, info) {
            return value == 10 || value == 50;
        }));
    </script>
</body>
  
</html>


Output:

RELATED ARTICLES

Most Popular

Dominic
32405 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6781 POSTS0 COMMENTS
Nicole Veronica
11928 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11995 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7165 POSTS0 COMMENTS
Thapelo Manthata
6862 POSTS0 COMMENTS
Umr Jansen
6847 POSTS0 COMMENTS