Returns true if object is a WeakMap (official Underscore docs). new WeakMap() passes; plain objects, Map, and other collections do not. Stable helper (Underscore 1.9+) — not deprecated.
Pass the required arguments shown below. Underscore object helpers usually return a new value — check whether the source object is mutated.
Syntax
Call _.isWeakMap. Start with this line.
Underscore
_.isWeakMap(object)
Call
What it does
_.isWeakMap(object)
Primary signature.
_.isWeakMap(...)
Call with the arguments your case needs.
Load Underscore with import _ from "underscore" (or the UMD CDN build) so these helpers are available as _.
Guard first. Skip non-WeakMaps so .get() never runs on the wrong type.
WeakMap path. Stored value 42 is returned for obj.
Fail closed.Map and plain objects return null.
Pattern. Type-check → then call collection methods.
Compatibility
Browser & Runtime Support
_.isWeakMap ships with Underscore.js 1.9+. It needs an ES2015+ runtime that provides WeakMap. Works in modern browsers (CDN or bundle) and current Node.js / Bun / Deno with npm install underscore.
✓ Stable · Underscore 1.9+
_.isWeakMap()
Available in [email protected]+ (UMD / ESM). Requires native WeakMap (ES2015). Fine on evergreen browsers and current Node LTS when Underscore is loaded.
98%Modern ES2015+ runtimes
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
_.isWeakMapUnderscore 1.9+ · ES2015+
Bottom line: Safe for modern apps once Underscore 1.9+ is loaded. Not a native browser API by itself — you need both Underscore and a WeakMap-capable engine. Prefer a pinned CDN version (e.g. [email protected]).
Frequently Asked Questions
_.isWeakMap(object) returns true only when the value is a WeakMap — for example new WeakMap(). Plain objects, Map, Set, WeakSet, arrays, null, and undefined return false.
_.isWeakMap(new WeakMap()) returns true. The docs pick a real WeakMap instance on purpose — that is the type the helper looks for.
No. Map and WeakMap are different types. WeakMap keys must be objects and are held weakly so they do not prevent garbage collection.
typeof new WeakMap() is "object", so typeof is too broad. Underscore uses the [object WeakMap] tag (or an IE11 fingerprint), which is more precise.
Use it as a guard before calling .get(), .set(), .has(), or .delete() when a value might be a WeakMap, a Map, or a plain object.
No. It is a stable Underscore helper added in version 1.9.0. Load Underscore 1.9+ in an ES2015+ environment and call _.isWeakMap(value).