Tuesday, November 18, 2025
HomeLanguagesJavascriptUnderscore.js _.matcher() Function

Underscore.js _.matcher() Function

Underscore.js is a JavaScript library that provides a lot of useful functions that helps in the programming in a big way like the map, filter, invoke etc. even without using any built-in objects.

The _.matcher() function is an inbuilt function in Underscore.js library of JavaScript which is used to find a predicate function which can inform you if a passed in object includes all the key-value properties that are given in the attrs parameter.

Syntax:

_.matcher(attrs)

Parameters: This function accepts a single parameter as mentioned above and described below:

  • attrs: It is the attribute which has a key and a value pair.

Return value: This method returns a predicate function.

Example 1:

Javascript




<!DOCTYPE html>
<html>
  
<head>
    <script type="text/javascript" src=
</head>
  
<body>
    <script type="text/javascript">
        console.log(_.matcher({ 
            picked: true, seeable: false 
        }));
    </script>
</body>
  
</html>


Output:

function(obj) { return isMatch(obj, attrs); }

Example 2:

Javascript




<!DOCTYPE html>
<html>
  
<head>
    <script type="text/javascript"
        src=
</head>
  
<body>
    <script type="text/javascript">
        var attr = "neveropen";
        console.log(_.matcher(attr));
    </script>
</body>
  
</html>


Output:

function(obj) { return isMatch(obj, attrs); }

Reference: https://underscorejs.org/#matcher

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
32402 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6772 POSTS0 COMMENTS
Nicole Veronica
11921 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11992 POSTS0 COMMENTS
Shaida Kate Naidoo
6899 POSTS0 COMMENTS
Ted Musemwa
7156 POSTS0 COMMENTS
Thapelo Manthata
6853 POSTS0 COMMENTS
Umr Jansen
6845 POSTS0 COMMENTS