Lodash _.isSymbol() method

Beginner
⏱️ 5 min read
📚 Updated: May 2026
🎯 3 Code examples
🚀 3 Try-it labs
Lodash

What you’ll learn

  • How _.isSymbol(value) detects Symbol primitives and boxed Symbol objects.
  • Why well-known symbols like Symbol.iterator qualify.
  • How this is broader than typeof value === "symbol".
  • Where Symbol guards belong—protocol keys, registry lookups, and meta-programming.

Prerequisites

You know Symbol() creates a unique primitive used for protocol keys and private fields.

  • You have seen Symbol.iterator or Symbol.for in practice.
  • Try-it labs load lodash from the CDN.

Overview

Reach for _.isSymbol when an API accepts symbolic keys, protocol identifiers, or sentinel values—and you must reject regular strings or numbers used by mistake.

Primitive + boxed

Both Symbol() and Object(Symbol()) qualify.

Well-known symbols

Symbol.iterator, Symbol.asyncIterator, etc. all pass.

Strings excluded

Description strings like "example" never qualify.

Syntax

javascript
_.isSymbol(value)
  • value: any value to test.
  • Returns: true when value is a Symbol primitive or boxed Symbol object; otherwise false.
1

Symbol primitives

The lodash docs example: well-known symbols like Symbol.iterator qualify, alongside fresh Symbol() values.

javascript
import isSymbol from "lodash/isSymbol";

console.log(
  "iter: " + isSymbol(Symbol.iterator) + "\n" +     // true (lodash docs)
  "fresh: " + isSymbol(Symbol("example")) + "\n" +    // true
  "forKey: " + isSymbol(Symbol.for("shared"))         // true
);
Try it Yourself
2

Boxed Symbol objects

Wrapping a Symbol via Object() makes its typeof become "object", but _.isSymbol still returns true via the tag check.

javascript
import isSymbol from "lodash/isSymbol";

const wrapped = Object(Symbol("wrapped"));

console.log(
  "boxed: " + isSymbol(wrapped) + "\n" +          // true
  "typeofRaw: " + (typeof wrapped)                 // "object"
);
Try it Yourself
3

Strings, numbers, and nullish

Lodash docs show _.isSymbol("abc") as false—a string description never makes a value symbolic.

javascript
import isSymbol from "lodash/isSymbol";

console.log(
  "abc: " + isSymbol("abc") + "\n" +     // false (lodash docs)
  "num: " + isSymbol(42) + "\n" +         // false
  "obj: " + isSymbol({}) + "\n" +          // false
  "nullVal: " + isSymbol(null)             // false
);
Try it Yourself

📋 _.isSymbol vs related checks

API / patternBehavior
_.isSymbol(x)true for primitive symbols and boxed Symbol objects.
typeof x === "symbol"Primitive only—misses Object(Symbol()) wrappers.
Object.prototype.toString.call(x)Tag [object Symbol]—the same idea lodash wraps.
Symbol.keyFor(x)Identifies Symbol.for-registered symbols only.

Pitfalls to avoid

Keys

for...in skips symbols

Use Object.getOwnPropertySymbols(obj) to iterate symbol keys; a plain for…in won’t see them.

Equality

Unique by construction

Symbol("x") === Symbol("x") is false—use Symbol.for("x") for shared registry keys.

JSON

Not serializable

Symbols are dropped by JSON.stringify; convert to strings or skip in your serializer.

❓ FAQ

Symbol() returns a primitive of type "symbol". You can wrap it via Object(sym) to get a boxed Symbol object.
Lodash checks typeof === "symbol" OR the [object Symbol] internal tag, so primitives and the rarely used boxed wrapper both qualify.
Yes—well-known symbols are real Symbol primitives, used as protocol keys for iterators, async iterators, hasInstance, and more.
typeof === "symbol" misses Object(Symbol()) wrappers; _.isSymbol catches them too via the internal tag check.

Summary

  • Purpose: recognize Symbol primitives and boxed wrappers before symbol-aware operations.
  • Remember: strings, numbers, and nullish values never qualify.
  • Next: explore more on Lodash _.isTypedArray().
Did you know?

Well-known symbols like Symbol.iterator and Symbol.asyncIterator are real Symbol primitives—_.isSymbol(Symbol.iterator) returns true per the lodash docs.

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.

6 people found this page helpful