VOOZH about

URL: https://www.geeksforgeeks.org/javascript/underscore-js-_-matcher-function/

⇱ Underscore.js _.matcher() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Underscore.js _.matcher() Function

Last Updated : 15 Oct, 2020

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:

Output:

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

Example 2:

Output:

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

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

Comment