Open In App

Underscore.js _.omit() Function

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

Syntax:

_.omit(object, *keys);

Parameters:

Return Value:

It returns a copy of the object that was filtered to omit the blacklisted keys.



Example 1: In this example, we are using the Underscore.js _.omit() function.




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

Output:



Example 2: In this example, we are using the Underscore.js _.omit() function.




<!DOCTYPE html>
<html>
 
<head>
    <script type="text/javascript" src=
    </script>
</head>
 
<body>
    <script type="text/javascript">
 
        let 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:


Article Tags :