Pass a value; if it is plain, treat it as a safe options/config map.
Start with a candidate value (plugin options, AJAX payload, config).
Call $.isPlainObject(value) — true means a plain {}-style object.
If true, merge or read keys (often with $.extend).
If false, reject or branch — do not treat arrays/DOM nodes as option maps.
Piece
Required?
Role
object
Yes
Value to test
Return
—
Boolean — plain object?
Follow-up
Usual
Merge 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)
Reference
Cheat Sheet
Keep these facts handy while checking plain objects with jQuery.
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.