jQuery isPlainObject() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Utilities

Definition

jQuery.isPlainObject(object) (alias $.isPlainObject) returns true when object is a plain object — created with {} or new Object (added in jQuery 1.4).

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$.isPlainObject(object)  → true | false

$.isPlainObject({})        // true
$.isPlainObject({ a: 1 })  // true
$.isPlainObject("test")    // false
$.isPlainObject([])        // false
CallWhat it does
isPlainObject()Learn jQuery.isPlainObject(): detect plain {} objects vs arrays DOM nodes and class instances, guard before extend, examples, pitfalls, and FAQs.

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Start with a candidate value (plugin options, AJAX payload, config).
Step 2Call $.isPlainObject(value) — true means a plain {}-style object.
Step 3If true, merge or read keys (often with $.extend).

Return Value

Return ValueDescription
BooleanOften true or false depending on the match or state.
Value / undefinedGetters usually return a value from the first matched element, or undefined when nothing applies.

jQuery Examples

Example 1 — Official Plain Object Checks

The jQuery API pattern: {} is plain; a string is not.

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

How It Works

  1. Empty literal. {} is the classic plain object → true.
  2. With keys. Adding properties does not change the prototype → still plain.
  3. Constructor. new Object() creates the same kind of plain object.

Example 2 — Values That Are Not Plain

Arrays, null, and DOM nodes look like “objects” but fail this test.

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

How It Works

  1. Array. [] has Array.prototype — use $.isArray instead.
  2. Null. null is not an object value for this helper → false.
  3. DOM. Element nodes are host objects, not plain maps.

Example 3 — Guard Options Before $.extend()

Only merge when the caller passed a plain options object.

jQuery
var defaults = { speed: 200, label: "Go" };

function mergeOptions(options) {
  if ($.isPlainObject(options)) {
    return $.extend({}, defaults, options);
  }
  return $.extend({}, defaults);
}

console.log(mergeOptions({ speed: 400 }).speed);  // 400
console.log(mergeOptions("oops").speed);          // 200
console.log(mergeOptions([1, 2]).label);          // "Go"
Try It Yourself

How It Works

  1. Defaults. Start with a known plain settings object.
  2. Gate. $.isPlainObject(options) must pass before merging.
  3. Merge. Plain options override defaults via $.extend.

Frequently Asked Questions

jQuery.isPlainObject(obj) returns true when obj is a plain object — typically created with {} or new Object(). It returns false for arrays, strings, DOM nodes, window, null, and most class instances.
Arrays are objects in JavaScript, but they use Array.prototype. $.isPlainObject([]) returns false because [] is not a plain key/value map. Use jQuery.isArray() (or Array.isArray) for arrays.
jQuery.extend() merges plain object properties. Plugin code often checks if ($.isPlainObject(options)) before merging user settings so arrays or DOM nodes are not treated as option maps.
$.type returns "object" for arrays, dates, and plain objects alike. isPlainObject narrows the test to simple {}-style objects that are safe to treat as option maps.
Yes. Objects created with Object.create(null) have no inherited prototype and are treated as plain objects by jQuery — useful for dictionary maps without inherited properties.
No. The jQuery API notes that host objects (browser environment objects) can behave inconsistently across browsers. Prefer testing your own plain data, not every host object.

Next: isWindow() Method

Learn how jQuery detects the browser window object.

isWindow() Method tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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.

9 people found this page helpful