Returns a predicate function that tells you whether a passed-in object contains all of the key/value properties present in attrs (official Underscore docs). Stable helper — not deprecated. Alias: matches.
Pass the required arguments shown below. Underscore object helpers usually return a new value — check whether the source object is mutated.
Syntax
Call _.matcher. Start with this line.
Underscore
_.matcher(attrs) / _.matches(attrs)
Call
What it does
_.matcher(attrs) / _.matches(attrs)
Primary signature.
_.matcher(...)
Call with the arguments your case needs.
Load Underscore with import _ from "underscore" (or the UMD CDN build) so these helpers are available as _.
Library declarations
Underscore
_.matcher(attrs) / _.matches(attrs)
Parameters
Parameter
Description
attrs
Required. Key/value pairs that must be present
Return Value
Return Value
Description
*
Predicate function (object) → boolean
Underscore.js Examples
Example 1 — Official: Ready + Filter
Build a reusable predicate and keep only matching items.
Same test; different shape — reusable function vs immediate boolean.
Underscore
var obj = {name: "moe", age: 50, stooge: true};
var attrs = {name: "moe", age: 50};
_.matcher(attrs)(obj); // → true
_.isMatch(obj, attrs); // → true
// Prefer matcher when you will reuse the test
// Prefer isMatch for a one-line check
isMatch. Takes object + attrs and returns the boolean directly — see _.isMatch.
Same rule. Both check that every pair in attrs is present.
Pick. Reuse across a list → matcher; one check → isMatch.
Compatibility
Browser & Runtime Support
_.matcher (alias _.matches) ships with Underscore.js (1.x). It runs anywhere Underscore runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install underscore.
✓ Stable · Underscore 1.x
_.matcher()
Available in [email protected] (UMD / ESM). Works in evergreen browsers and current Node LTS when Underscore is loaded.
100%With Underscore 1.x
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
_.matcherUnderscore 1.x+
Bottom line: Safe for production once Underscore is on the page or in your bundle. Not a native browser API by itself — load Underscore first. Prefer a pinned CDN version (e.g. [email protected]).
Frequently Asked Questions
_.matcher(attrs) returns a predicate function. Call that function with an object and it returns true if the object contains every key-value pair from attrs. Extra properties on the object are allowed.
Yes. matches is the documented alias of matcher. Either name refers to the same function.
_.isMatch(object, attrs) answers immediately with true or false. _.matcher(attrs) returns a reusable predicate you can pass to _.filter, _.find, _.reject, and similar helpers.
No. The object only needs to contain all pairs in attrs. Extra keys do not fail. A missing key or a different value does fail.
No. Values use SameValueZero-style checks (like Underscore's isMatch). Nested objects/arrays need the same reference unless you compare with _.isEqual yourself.
No. It is a stable Underscore object helper (alias: matches). Load Underscore 1.x and call _.matcher(attrs).