jQuery.isEmptyObject(object) (alias $.isEmptyObject) returns true when the object has no enumerable properties (since jQuery 1.4). Empty {} is true; any key makes it false.
Syntax
Start with these common calls. Keep them short and readable.
Learn jQuery.isEmptyObject(): check if a plain object has no enumerable properties, pair with isPlainObject, compare with Object.keys, defaults with extend, examples, pitfalls, and FAQs.
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Start with a plain object (options, config, API payload).
Step 2
Optionally confirm with $.isPlainObject(obj).
Step 3
Call $.isEmptyObject(obj).
Return Value
Return Value
Description
Boolean
Often true or false depending on the match or state.
Value / undefined
Getters usually return a value from the first matched element, or undefined when nothing applies.
Plain literals. Both APIs agree on {} and { x: 1 }.
Object.keys. Counts only own enumerable properties.
isEmptyObject. Uses for...in (can include inherited enumerable keys).
Frequently Asked Questions
jQuery.isEmptyObject(object) returns true when the object has no enumerable properties (as seen by for...in). An empty literal {} returns true; { foo: "bar" } returns false.
Yes. The official docs say the argument should always be a plain JavaScript Object. DOM nodes, primitives, and host objects may give inconsistent results across browsers. Confirm with $.isPlainObject() when unsure.
Object.keys counts only own enumerable properties. Since jQuery 1.4, isEmptyObject uses for...in and can also see inherited enumerable properties on the prototype. For typical {} literals both usually agree.
The method expects an object. Passing null or undefined can throw when the internal loop runs. Guard first, or normalize with options || {}.
It is meant for plain objects, not arrays. Use $.isArray() / Array.isArray() and .length for arrays.
A common pattern: if user options are empty, keep defaults; otherwise merge with $.extend({}, defaults, userOptions).
Yes, if jQuery is loaded. It is a data utility and does not need a DOM. Many Node apps prefer Object.keys(obj).length === 0 for own-property checks.