Underscore.js _.isSymbol() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Object

Definition

Returns true if object is a Symbol (official Underscore docs). Symbol(), described symbols, well-known symbols, and boxed symbols pass; strings and numbers 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 _.isSymbol. Start with this line.

Underscore
_.isSymbol(object)
CallWhat it does
_.isSymbol(object)Primary signature.
_.isSymbol(...)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
_.isSymbol(object)

Parameters

ParameterDescription
objectRequired. Value to test

Return Value

Return ValueDescription
*true or false

Underscore.js Examples

Example 1 — Official: Symbol()

The docs check a freshly created Symbol.

Underscore
_.isSymbol(Symbol());
// → true
Try It Yourself

How It Works

  1. Create. Symbol() returns a unique Symbol value.
  2. Tag check. Underscore sees [object Symbol] → true.
  3. Official example. This is the sample from the Underscore documentation.
  4. Read-only. Nothing is mutated; you only get a boolean.

Example 2 — Described and Shared Symbols

Descriptions and Symbol.for do not change the type.

Underscore
_.isSymbol(Symbol("id"));
// → true

_.isSymbol(Symbol.for("id"));
// → true

_.isSymbol(Symbol.iterator);
// → true  (well-known symbol)
Try It Yourself

How It Works

  1. Described. Symbol("id") adds a debug label — still a Symbol.
  2. Shared registry. Symbol.for("id") looks up/creates a global Symbol — still a Symbol.
  3. Well-known. Built-ins like Symbol.iterator also pass.
  4. Takeaway. Creation style does not matter — the type does.

Example 3 — Boxed Symbol vs typeof

Object(Symbol()) is an object to typeof, but Underscore still treats it as a Symbol.

Underscore
typeof Symbol();              // → "symbol"
typeof Object(Symbol());      // → "object"

_.isSymbol(Symbol());         // → true
_.isSymbol(Object(Symbol())); // → true
_.isSymbol("symbol");         // → false
Try It Yourself

How It Works

  1. Primitive. Symbol() has typeof "symbol".
  2. Boxed trap. Object(Symbol()) makes typeof report "object".
  3. Tag wins. Underscore uses [object Symbol], so both forms pass.
  4. Strings fail. The word "symbol" is still text — use _.isString.

Example 4 — Guard Unique Keys

Only set a Symbol key when the value really is a Symbol.

Underscore
function setUnique(obj, key, value) {
  if (!_.isSymbol(key)) {
    return false;
  }
  obj[key] = value;
  return true;
}

var secret = Symbol("secret");
var bag = {};

setUnique(bag, secret, 1);   // → true
setUnique(bag, "secret", 2); // → false
Object.keys(bag).length;     // → 0  (Symbol keys are hidden from keys)
Try It Yourself

How It Works

  1. Guard first. Reject non-Symbol keys so string keys are not set this way.
  2. Symbol path. secret passes → value 1 is stored.
  3. String rejected. "secret" fails the check → returns false.
  4. Hidden from keys. Object.keys does not list Symbol keys (length stays 0).

Browser & Runtime Support

_.isSymbol ships with Underscore.js 1.9+. It needs an ES2015+ runtime that provides Symbol. Works in modern browsers (CDN or bundle) and current Node.js / Bun / Deno with npm install underscore.

✓ Stable · Underscore 1.9+

_.isSymbol()

Available in [email protected]+ (UMD / ESM). Requires native Symbol (ES2015). Fine on evergreen browsers and current Node LTS when Underscore is loaded.

98% Modern ES2015+ runtimes
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
_.isSymbol Underscore 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 Symbol-capable engine. Prefer a pinned CDN version (e.g. [email protected]).

Frequently Asked Questions

_.isSymbol(object) returns true only when the value is a Symbol — Symbol(), Symbol("id"), Object(Symbol()), Symbol.for("id"), or a well-known symbol such as Symbol.iterator. Numbers, strings, functions, and plain objects return false.
_.isSymbol(Symbol()) returns true. The docs pick a real Symbol on purpose — that is the type the helper looks for.
Yes. Symbol("description"), Symbol.for("key"), and Object(Symbol()) all return true. Boxing wraps the symbol, but the internal tag is still [object Symbol].
typeof Symbol() is "symbol", which is accurate for primitives. typeof Object(Symbol()) is "object", so typeof misses boxed symbols. Underscore’s tag check accepts both.
Use it as a guard before treating a value as a unique property key, or when filtering Object.getOwnPropertySymbols results and mixed value lists.
No. It is a stable Underscore helper (added in 1.9.0). Load Underscore 1.x in an ES2015+ environment and call _.isSymbol(value).

Next: _.isMap()

Learn how to detect Map objects — key/value collections that can use any key type.

_.isMap() 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