Underscore.js _.isObject() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Object

Definition

Returns true if value is an Object (official Underscore docs). Arrays and functions count as objects; normal strings and numbers do not. Stable helper — 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 _.isObject. Start with this line.

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

Parameters

ParameterDescription
valueRequired. Value to test

Return Value

Return ValueDescription
*true or false

Underscore.js Examples

Example 1 — Official: Object vs Number

The docs contrast a plain object with a number.

Underscore
_.isObject({});
// → true

_.isObject(1);
// → false
Try It Yourself

How It Works

  1. Empty object. {} has typeof "object" and is truthy → true.
  2. Number. 1 has typeof "number" → not a function or object → false.
  3. Official pair. This is the example from the Underscore documentation.
  4. Read-only. Nothing is mutated; you only get a boolean.

Example 2 — Arrays and Functions Pass

In JavaScript, arrays and functions are objects — Underscore agrees.

Underscore
_.isObject([1, 2, 3]);
// → true

_.isObject(function () {});
// → true

_.isArray([1, 2, 3]);
// → true  (narrower check when you need an array)
Try It Yourself

How It Works

  1. Array. [] is typeof "object" and truthy → isObject is true.
  2. Function. typeof "function" is an explicit pass in Underscore’s check.
  3. Narrower tool. Need only arrays? Prefer _.isArray.
  4. Takeaway. isObject is a wide net, not a plain-object-only test.

Example 3 — null vs typeof

typeof null is "object", but Underscore correctly returns false.

Underscore
typeof null;
// → "object"   ← JavaScript quirk

_.isObject(null);
// → false

_.isNull(null);
// → true
Try It Yourself

How It Works

  1. typeof trap. typeof null reports "object" — do not trust that alone.
  2. Truthiness filter. Underscore requires !!obj, so null fails.
  3. Strict null. Use _.isNull when you want null specifically.
  4. Rule. Prefer _.isObject over raw typeof for this check.

Example 4 — Guard Before _.keys

Use isObject as a safe gate before reading keys.

Underscore
function safeKeys(value) {
  if (!_.isObject(value)) {
    return [];
  }
  return _.keys(value);
}

safeKeys({ a: 1, b: 2 });  // → ["a", "b"]
safeKeys(null);            // → []
safeKeys(42);              // → []
Try It Yourself

How It Works

  1. Guard first. Skip non-objects so you never treat null or 42 as a map.
  2. Object path. For { a: 1, b: 2 }, _.keys returns the own keys.
  3. Fail closed. Primitives and null return an empty array.
  4. Pattern. Broad type check → then a specific helper.

Browser & Runtime Support

_.isObject 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

_.isObject()

Available in [email protected] (UMD / ESM). Works in evergreen browsers and current Node LTS when Underscore is loaded.

100% With Underscore 1.x
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
_.isObject Underscore 1.x+

Bottom line: Safe for production once Underscore is on the page or in your bundle. Not a native browser API — load Underscore first. Prefer a pinned CDN version (e.g. [email protected]).

Frequently Asked Questions

_.isObject(value) returns true when the value is an object or a function. Plain objects, arrays, dates, and functions all pass. Primitives like numbers and strings return false.
No. Even though typeof null is "object" in JavaScript, Underscore uses !!obj so null fails. That is intentional and matches the official idea that null is not a usable object.
Yes in JavaScript. _.isObject([]) and _.isObject(function(){}) both return true. Use _.isArray or _.isFunction when you need a narrower check.
typeof null is "object", which is a long-standing JavaScript quirk. _.isObject(null) is false. typeof also cannot tell arrays from plain objects; both are "object".
Use it as a broad guard before treating a value as an object (for example before _.keys). Prefer _.isArray, _.isFunction, or _.isNull when you need a specific type.
No. It is a stable Underscore type helper. Load Underscore 1.x (CDN or npm) and call _.isObject(value).

Next: _.isArguments()

Learn how to detect the Arguments object — array-like, but not an Array.

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