jQuery jQuery.isPlainObject() Method

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Plain object

What You’ll Learn

The jQuery.isPlainObject() utility returns true when a value is a plain {}-style object — safe for $.extend() and option maps. This tutorial covers syntax, five worked examples from the official API, comparisons with $.type(), and guards before merging plugin settings.

01

Syntax

$.isPlainObject(obj)

02

Boolean

true / false

03

{} yes

Literal

04

[] no

Not plain

05

DOM no

Not plain

06

extend

Guard merge

Introduction

In JavaScript, many values are technically “objects” — arrays, DOM nodes, dates, and custom class instances all report typeof x === "object". jQuery plugins, however, usually expect configuration as a plain object: a simple key/value map created with {} or new Object().

jQuery provides jQuery.isPlainObject() (also written $.isPlainObject()) to distinguish those simple maps from everything else. Use it before $.extend(), before iterating option keys, and anywhere user input must be a plain settings object — not an array, DOM node, or class instance.

Understanding the jQuery.isPlainObject() Method

jQuery.isPlainObject(obj) returns true when obj is an object whose internal prototype is Object.prototype or null — the shapes produced by object literals and Object.create(null).

It returns false for null, arrays, functions, DOM elements, window, document, and instances of custom constructors whose prototype chain does not lead to plain Object.

💡
Beginner Tip

Think “plain object” = settings JSON shape: { speed: 400, easing: "swing" }. Not [], not document.body, not new Date().

📝 Syntax

General form of jQuery.isPlainObject:

jQuery
jQuery.isPlainObject( obj )
// or
$.isPlainObject( obj )

Parameters

  • obj — any JavaScript value to test.

Return value

  • true if obj is a plain object.
  • false for all other types and non-plain objects.

Minimal workflow

jQuery
if ($.isPlainObject(userOptions)) {
  settings = $.extend({}, defaults, userOptions);
}

⚡ Quick Reference

Value$.isPlainObject()
{}true
new Object()true
Object.create(null)true
[]false
nullfalse
window / documentfalse
Custom class instancefalse (usually)

📋 $.isPlainObject vs $.type vs $.isEmptyObject

Three object-related checks — shape, type string, and emptiness.

$.isPlainObject
{} shape

Plain key/value maps only

$.type
"object"

Arrays & dates too

$.isEmptyObject
no keys

Emptiness, not plainness

Together
plain + keys

Safe extend pattern

Examples Gallery

Each example uses $.isPlainObject(). Open DevTools or use the Try-it links to run them interactively.

📚 Getting Started

Official jQuery API examples — literals and new Object() pass.

Example 1 — Plain Object Literals Pass

The canonical passing cases from the jQuery documentation.

jQuery
console.log($.isPlainObject({}));           // true
console.log($.isPlainObject({ a: 1 }));     // true
console.log($.isPlainObject(new Object())); // true
Try It Yourself

How It Works

Object literals and new Object() inherit directly from Object.prototype — the definition of “plain” in jQuery’s utility layer.

📈 Practical Patterns

Rejections, extend guards, class instances, and paired checks.

Example 2 — Arrays, DOM, and null Are Not Plain

From the official docs — values that look like objects but fail the test.

jQuery
console.log($.isPlainObject([]));       // false
console.log($.isPlainObject(null));     // false
console.log($.isPlainObject(window));    // false
console.log($.isPlainObject(document));  // false
Try It Yourself

How It Works

Arrays use Array.prototype; DOM nodes use element prototypes; null is not an object at all. Merging any of these with $.extend would corrupt settings.

Example 3 — Guard Before $.extend()

Only merge when user input is a plain object.

jQuery
var defaults = { theme: "light", lang: "en" };

function resolveSettings(input) {
  if (!$.isPlainObject(input)) {
    return $.extend({}, defaults);
  }
  return $.extend({}, defaults, input);
}

console.log(resolveSettings({ theme: "dark" }).theme); // dark
console.log(resolveSettings([]).theme);                // light
Try It Yourself

How It Works

Passing an array to $.extend would copy numeric indices as keys — almost never what plugin authors intend. isPlainObject blocks that mistake.

Example 4 — Custom Class Instances Fail

Objects from constructors with their own prototype are not plain.

jQuery
function Config() {
  this.speed = 300;
}

console.log($.isPlainObject(new Config())); // false
console.log($.isPlainObject({ speed: 300 })); // true
Try It Yourself

How It Works

new Config() inherits from Config.prototype, not Object.prototype directly. For plugin options, prefer plain literals over class instances.

Example 5 — Combine With $.isEmptyObject()

Confirm plain shape, then check whether any keys exist before merging.

jQuery
var defaults = { size: "md" };

function applyOptions(opts) {
  if ($.isPlainObject(opts) && !$.isEmptyObject(opts)) {
    return $.extend({}, defaults, opts);
  }
  return $.extend({}, defaults);
}

console.log(applyOptions({}).size);           // md
console.log(applyOptions({ size: "lg" }).size); // lg
console.log(applyOptions(null).size);          // md
Try It Yourself

How It Works

isPlainObject answers “is it the right shape?” isEmptyObject answers “does it have any keys?” Together they form the standard jQuery plugin options pipeline.

🚀 Common Use Cases

  • Plugin options — validate settings before $.extend.
  • AJAX config — ensure payload maps are plain objects.
  • Deep extend guards — only recurse into plain nested objects.
  • JSON-like data — confirm parsed data is a key/value map.
  • Reject DOM nodes — block accidental element merges.
  • Pair with isEmptyObject — shape check plus emptiness check.

🧠 How jQuery.isPlainObject() Inspects Prototypes

1

Reject non-objects

null, primitives, and functions return false immediately.

Filter
2

Read prototype

jQuery inspects Object.getPrototypeOf(obj) (or legacy equivalent).

Proto
3

Match Object

Prototype must be null or Object.prototype for plain status.

Compare
4

Return boolean

Arrays, DOM nodes, and class instances fail the prototype test.

📝 Notes

  • Available since jQuery 1.2 — core to $.extend internals.
  • $.type(obj) === "object" is broader — always use isPlainObject for extend targets.
  • Object.create(null) is considered plain — no inherited keys.
  • Cross-frame plain objects are plain if their prototype chain qualifies.
  • Does not validate nested structure — only top-level plainness.
  • Related: $.extend(), $.isEmptyObject(), $.type().

Browser Support

jQuery.isPlainObject() has been part of jQuery since jQuery 1.2+. It works wherever jQuery runs — all modern browsers and legacy IE when paired with a supported jQuery build.

jQuery 1.2+

jQuery jQuery.isPlainObject()

Supported in jQuery 1.x, 2.x, and 3.x. Prototype inspection is consistent across browsers via jQuery's implementation.

100% With jQuery loaded
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
jQuery.isPlainObject() Universal

Bottom line: Safe in any project that already includes jQuery. Without jQuery, compare Object.getPrototypeOf(obj) === Object.prototype or proto === null.

Conclusion

The jQuery.isPlainObject() utility separates simple {} configuration maps from arrays, DOM nodes, class instances, and other object-like values. It is the gatekeeper before $.extend() and the companion to $.isEmptyObject() in plugin code.

Remember: plain means prototype-safe for merging — not merely typeof "object". Validate shape first, then merge or iterate keys with confidence — and explore jQuery.isWindow() when resolving browser contexts.

💡 Best Practices

✅ Do

  • Check $.isPlainObject(options) before $.extend
  • Pair with $.isEmptyObject for full option validation
  • Use plain literals for plugin configuration
  • Reject arrays and DOM nodes explicitly in APIs
  • Prefer Object.assign on verified plain objects in modern code

❌ Don’t

  • Assume typeof x === "object" means plain
  • Pass class instances as plugin options without converting
  • Merge document or window into settings
  • Use isPlainObject to detect arrays — use $.isArray
  • Skip validation because input “looks like” an object

Key Takeaways

Knowledge Unlocked

Five things to remember about jQuery.isPlainObject()

Detect plain objects the jQuery way.

5
Core concepts
02

Literal

Passes

Plain
🚫 03

Array

Fails

Reject
🔗 04

extend

Guard

Pattern
🔍 05

Proto

Object.prototype

How

❓ Frequently Asked Questions

jQuery.isPlainObject(obj) returns true when obj is a plain object — typically created with {} or new Object() — whose prototype is Object.prototype or null. It returns false for arrays, DOM nodes, window, document, null, and most class instances.
Arrays are objects in JavaScript but have Array.prototype, not Object.prototype. $.isPlainObject([]) returns false because [] is not a plain key/value map — use $.isArray() for arrays instead.
jQuery.extend() merges plain object properties. Plugin code often checks if ($.isPlainObject(options)) before merging user settings — preventing accidental merges from arrays or DOM nodes.
typeof and $.type return "object" for arrays, dates, and plain objects alike. isPlainObject narrows the test to simple {}-style objects safe for extend and option maps.
Yes. Objects created with Object.create(null) have no inherited prototype chain and are treated as plain objects by jQuery — useful for dictionary maps without inherited properties.
Check type first, then emptiness: if ($.isPlainObject(opts) && !$.isEmptyObject(opts)) { settings = $.extend({}, defaults, opts); }. isPlainObject confirms shape; isEmptyObject confirms content.
Did you know?

jQuery’s own $.extend() uses plain-object detection internally — that is why passing an array or DOM node as an options argument produces odd numeric keys instead of named settings. The official isPlainObject demo with window and document exists to show exactly what extend must reject.

Continue to jQuery.isWindow()

Detect browser window objects and iframe contentWindow values.

isWindow() 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.

6 people found this page helpful