jQuery isPlainObject() Method

Beginner
6 min read
Updated: Oct 2026
4 examples
Live preview

What Is isPlainObject()?

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

Remember
$.isPlainObject(object)  → true | false

$.isPlainObject({})        // true
$.isPlainObject({ a: 1 })  // true
$.isPlainObject("test")    // false
$.isPlainObject([])        // false
NeedUse
Plain {} map?$.isPlainObject(obj)
Array?$.isArray(obj)
Empty plain object?$.isEmptyObject(obj)

How to Use isPlainObject()

Pass a value; if it is plain, treat it as a safe options/config map.

  1. Start with a candidate value (plugin options, AJAX payload, config).
  2. Call $.isPlainObject(value) — true means a plain {}-style object.
  3. If true, merge or read keys (often with $.extend).
  4. If false, reject or branch — do not treat arrays/DOM nodes as option maps.
PieceRequired?Role
objectYesValue to test
Return—Boolean — plain object?
Follow-upUsualMerge with $.extend or read keys

Pseudocode

Pseudocode
function isPlainObject(object):
    if object is null or not an object:
        return false
    if object is array, DOM node, window, or class instance:
        return false
    // created with {} or new Object (or Object.create(null))
    return true

// Typical plugin flow:
if $.isPlainObject(options):
    settings = $.extend({}, defaults, options)
else:
    settings = $.extend({}, defaults)

Cheat Sheet

Keep these facts handy while checking plain objects with jQuery.

TopicDetail
SyntaxjQuery.isPlainObject(object) / $.isPlainObject(object)
SincejQuery 1.4
True{}, { a: 1 }, new Object(), Object.create(null)
False[], "test", DOM nodes, null, class instances
Pair with$.extend(), $.isEmptyObject()
Type string$.type(obj) → often "object" (broader)

Live Preview

Pick a sample value and see what $.isPlainObject() returns.

Browser demo of $.isPlainObject() — same idea as the examples below.

Result
$.isPlainObject({})
→ true

/* created with {} */

jQuery Examples

Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.

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.
  4. String. "test" is a primitive string → false (official API sample).

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.
  4. Window. The global window is not a plain options object.

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.
  4. Fallback. Strings/arrays are ignored — defaults stay intact.

Example 4 — Object.create(null) vs a Class Instance

Null-prototype dictionaries count as plain; custom classes usually do not.

jQuery
var dict = Object.create(null);
dict.x = 1;

function Box(n) { this.n = n; }

console.log($.isPlainObject(dict));        // true
console.log($.isPlainObject(new Box(1)));  // false
Try It Yourself

How It Works

  1. Null proto. Object.create(null) has no inherited keys — jQuery treats it as plain.
  2. Assign. Adding dict.x does not change that result.
  3. Class. new Box(1) uses a custom prototype → not plain.
  4. Rule. Prefer plain objects (or null-proto maps) for option bags.

Edge Cases & Pitfalls

Check these before relying on $.isPlainObject() in plugins.

arrays

[] is an object — but not plain

typeof [] === "object" is true, yet $.isPlainObject([]) is false. Use $.isArray for lists.

host

Host objects can surprise you

The official docs warn that host objects are inconsistent across browsers. Test your own option maps, not every browser object.

type

$.type is broader

$.type(x) === "object" also matches arrays and dates. Prefer isPlainObject when you need a merge-safe map.

empty

Plain ≠ non-empty

{} is plain and empty. Pair with $.isEmptyObject when you need both shape and content.

Browser Support

jQuery.isPlainObject() is available since jQuery 1.4+ in all modern browsers with jQuery loaded. It is a jQuery utility (not a native browser API).

✓ jQuery 1.4+ · Stable

jQuery.isPlainObject()

Works in Chrome, Firefox, Safari, and Edge whenever jQuery 1.4+ is loaded. Prefer testing plain app data over host objects.

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
$.isPlainObject() jQuery 1.4+

Bottom line: Use $.isPlainObject(obj) in the browser with jQuery. Guard plugin options before $.extend; avoid relying on host-object edge cases.

Performance Notes

ApproachCostBest for
$.isPlainObject(o)O(1)Option/config gates
$.type(o) === "object"O(1)Broad type label (less strict)
$.extend without a gateRiskyAvoid for untrusted inputs

The check is cheap. Use it at API boundaries (plugin options, merge helpers) — not inside tight inner loops over thousands of values.

Key Takeaways

  • Role: $.isPlainObject(o) → plain {} / new Object?
  • Rejects: arrays, strings, DOM, null, most class instances.
  • Use: gate options before $.extend.
  • Note: host objects can be inconsistent — test your own data.

One line: use $.isPlainObject to confirm a merge-safe {} map before reading keys or calling $.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()

Learn how jQuery detects the browser window object.

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.

9 people found this page helpful