What Is a Plain Object in Lodash isPlainObject?

The Lodash library provides the _.isPlainObject method to determine whether a given value is a plain JavaScript object. In Lodash, a plain object is strictly defined as an object created by the Object constructor, an object literal ({}), or an object with a [[Prototype]] of null. This article covers the exact technical criteria Lodash uses to identify plain objects, what values qualify, and which object types are excluded.

The Technical Definition

Lodash defines a plain object as any value that meets the following internal criteria:

  1. Object-like Type: The value must be an object (typeof value === 'object') and cannot be null.
  2. Object Tag: The internal [[Class]] or Symbol.toStringTag must match '[object Object]' (checked via Object.prototype.toString.call(value)).
  3. Prototype Check: The object's prototype must either be null or directly resolve to Object.prototype.

To verify the prototype, Lodash traverses the prototype chain. If the prototype of the object is null (such as objects created via Object.create(null)), it returns true. If the object has a prototype, Lodash checks whether the constructor of the top-level prototype is the native Object constructor.

Values That Return true

The _.isPlainObject function returns true for objects created in the following ways:

Values That Return false

Any value that inherits from a prototype other than Object.prototype or null is considered a non-plain object. The function returns false for:

Why the Distinction Matters

In JavaScript, arrays, functions, and class instances are technically objects. However, utilities that serialize, deep clone, or merge structured data often require simple key-value stores rather than stateful instances or complex structures. Lodash’s _.isPlainObject ensures that operations like deep merging (_.merge) only traverse data dictionaries without unintentionally mutating complex instances or invoking unintended prototypes.