Lodash _.isObject() method

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

What you’ll learn

  • How _.isObject(value) filters nullish values then inspects typeof.
  • Why arrays, plain objects, and functions all qualify.
  • How this differs from _.isObjectLike and _.isPlainObject.
  • When to narrow further before treating input as a data record.

Prerequisites

You understand JavaScript typeof quirks (including typeof null === "object") at a basic level.

  • You know arrays are objects in JavaScript.
  • Try-it labs load lodash from the CDN.

Overview

Reach for _.isObject when guarding generic merges, serializers, or middleware that should reject primitives yet accept structured builtins—from POJOs and arrays to callables.

Broad structural

Arrays, dates, regex literals, and plain maps-of-keys qualify.

Functions allowed

Treats callable references as object-category values.

Nullish out

null and undefined fail before typeof tricks matter.

Syntax

javascript
_.isObject(value)
  • value: any value to test.
  • Returns: true when value is non-nullish and typeof is "object" or "function".
1

Plain objects and arrays

Lodash documents both collections as objects.

javascript
import isObject from "lodash/isObject";

console.log(
  "pojo: " + isObject({}) + "\n" +              // true
  "array: " + isObject([1, 2, 3])             // true
);
Try it Yourself
2

Nullish and primitives

null is ruled out explicitly; strings and numbers stay primitives.

javascript
import isObject from "lodash/isObject";

console.log(
  "nullVal: " + isObject(null) + "\n" +       // false (lodash docs)
  "undef: " + isObject(undefined) + "\n" +    // false
  "num: " + isObject(42)                     // false
);
Try it Yourself
3

Functions: _.isObject vs _.isObjectLike

Functions count as objects for lodash; _.isObjectLike excludes them.

javascript
import isObject from "lodash/isObject";
import isObjectLike from "lodash/isObjectLike";

console.log(
  "fnIsObject: " + isObject(function () {}) + "\n" +       // true (lodash docs use _.noop)
  "fnObjectLike: " + isObjectLike(function () {})         // false
);
Try it Yourself

📋 _.isObject vs related helpers

APIBehavior
_.isObject(x)Non-nullish object or function typeof.
_.isObjectLike(x)Non-nullish typeof === "object" only—functions excluded.
_.isPlainObject(x)Simple dictionaries—arrays, dates, and classes fail.
x instanceof ObjectOften similar but prototype quirks exist for primitives.

Pitfalls to avoid

Semantics

“JSON-like” assumptions

_.isObject is broad—validate shapes separately before treating payloads as records.

DOM

Host objects

Elements and exotic builtins usually still report typeof object—pair with feature checks.

Perf

Micro-optimization

Inline guards suffice in hot paths; lodash shines when chaining readability matters.

❓ FAQ

Yes. Arrays have typeof "object" and are not nullish.
Yes for lodash—functions satisfy typeof "function", which _.isObject deliberately allows.
isPlainObject narrows to simple dictionaries from Object or null prototypes—classes and builtins fail.
typeof null is the legacy "object" quirk, but lodash rejects null and undefined up front with value != null.

Summary

  • Purpose: coarse filter for non-null structural/callable values.
  • Remember: tighten with _.isPlainObject, Array.isArray, or schema validators when shape matters.
  • Next: explore more on Lodash _.isObjectLike().
Did you know?

_.isObject is defined as value != null && (typeof value === "object" || typeof value === "function")—so typeof function counts, unlike _.isObjectLike, which only allows typeof "object".

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