Lodash _.isSet() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Lang

Definition

Checks if value is classified as a Set object. Part of Lodash Lang since 4.3.0 (stable — not deprecated).

Note: Tag-based detection ([object Set]) stays reliable across realms where instanceof Set can fail (iframes / other VMs).

Syntax

Call _.isSet. Start with this line.

Lodash
_.isSet(value)
CallWhat it does
_.isSet(value)Primary signature.

Prefer import isSet from "lodash/isSet" when you want a smaller bundle.

Library declarations
Lodash
_.isSet(value)

Parameters

ParameterDescription
valueRequired. The value to check

Return Value

Return ValueDescription
*true if Set, else false

Lodash Examples

Example 1 — Official: new Set

A real Set instance is classified as a Set.

Lodash
_.isSet(new Set);
// → true
Try It Yourself

How It Works

  1. new Set. Creates a native Set instance.
  2. Brand. Lodash sees the [object Set] tag.
  3. Result. Returns true.
  4. Empty OK. Size does not matter for the type check.

Example 2 — Official: WeakSet

WeakSet is a different built-in — it does not pass.

Lodash
_.isSet(new WeakSet);
// → false
Try It Yourself

How It Works

  1. WeakSet. Separate type with its own tag.
  2. Not Set. Lodash does not treat them as interchangeable.
  3. Result. Returns false.
  4. Use. Call _.isWeakSet instead.

Example 3 — Set With Members

Populated Sets still pass — contents are irrelevant.

Lodash
var s = new Set([1, 2, 2]);

_.isSet(s);
// → true

s.size;
// → 2   // duplicates collapsed
Try It Yourself

How It Works

  1. Construct. Seed the Set from an array.
  2. Type first. _.isSet only asks “is this a Set?”.
  3. Members. Duplicates are unique inside the Set.
  4. Guard. Use this before calling Set-only methods.

Example 4 — Plain Object Lookalike

Objects that mimic Set methods are still not Sets.

Lodash
var fake = { add: function () {}, has: function () {}, size: 0 };

_.isSet(fake);
// → false

_.isSet({});
// → false
Try It Yourself

How It Works

  1. Duck typing. Method names alone do not count.
  2. Brand required. Must be a real Set instance.
  3. Both fail. Fake and {} return false.
  4. Safe. Avoids treating lookalikes as Sets.

Example 5 — Array, Map & Nullish

Common “collection-like” values that are not Sets.

Lodash
_.isSet([1, 2, 3]);
// → false

_.isSet(new Map());
// → false

_.isSet(null);
// → false
Try It Yourself

How It Works

  1. Array. Indexed list — use _.isArray.
  2. Map. Key/value store — use _.isMap.
  3. Nullish. null / undefined fail cleanly.
  4. Rule. Only values branded as Set pass.

Browser & Runtime Support

_.isSet is a Lodash Lang helper since 4.3.0. It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native Set itself needs ES2015+ environments.

✓ Stable · Lodash 4.3.0+

_.isSet()

Available in [email protected] full builds and the lodash/isSet modular import. Requires a runtime that provides the Set built-in (all modern engines).

100% With Lodash 4.3+
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.isSet Lodash 4.3.0+

Bottom line: Safe for production once Lodash is loaded on an ES2015+ runtime. Prefer import isSet from "lodash/isSet" for smaller bundles. Use it before Set-only operations.

Frequently Asked Questions

_.isSet(value) returns true if value is classified as a Set object, otherwise false. WeakSet, arrays, Maps, and plain objects all return false.
WeakSet is a different built-in type with its own brand ([object WeakSet]). Lodash exposes _.isWeakSet for that check.
Yes. _.isSet(new Set()) is true whether the Set has members or not — the check is about type, not size.
No. Duck-typed objects are not Sets. Lodash looks for a real Set classification, not method names.
Yes. Instances that brand as Set (including typical subclasses) return true.
Use import isSet from "lodash/isSet" or require("lodash/isSet"). Full build: import _ from "lodash" then _.isSet.

Next: _.isString()

Check whether a value is classified as a string.

_.isString() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful