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
Fundamentals
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.
Concept
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().
Foundation
📝 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);
}
Cheat Sheet
⚡ Quick Reference
Value
$.isPlainObject()
{}
true
new Object()
true
Object.create(null)
true
[]
false
null
false
window / document
false
Custom class instance
false (usually)
Compare
📋 $.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
Hands-On
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.
isPlainObject answers “is it the right shape?” isEmptyObject answers “does it have any keys?” Together they form the standard jQuery plugin options pipeline.
Applications
🚀 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.
Prototype must be null or Object.prototype for plain status.
Compare
4
✅
Return boolean
Arrays, DOM nodes, and class instances fail the prototype test.
Important
📝 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().
Compatibility
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 ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll 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.
Wrap Up
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.
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
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about jQuery.isPlainObject()
Detect plain objects the jQuery way.
5
Core concepts
📄01
$.isPlainObject
{} maps only
API
✅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.