jQuery.isPlainObject()

Check to see if an object is a plain object (created using "{}" or "new Object").

jQuery.isPlainObject(object)🡢 Boolean

object PlainObjectThe object that will be checked to see if it's a plain object.

Note: Host objects (or objects used by browser host environments to complete the execution environment of ECMAScript) have a number of inconsistencies which are difficult to robustly feature detect cross-platform. As a result of this, $.isPlainObject() may evaluate inconsistently across browsers in certain instances.

An example of this is a test against document.location using $.isPlainObject() as follows:

console.log($.isPlainObject(document.location));

which throws an invalid pointer exception in IE8. With this in mind, it's important to be aware of any of the gotchas involved in using $.isPlainObject() against older browsers. A couple basic examples that do function correctly cross-browser can be found below.

Check an object to see if it's a plain object.

HTML
jQuery.isPlainObject({}); // true
jQuery.isPlainObject("test"); // false
DEMO

Looking for a Web Developer?

👋

Hi! I'm Basti, author of this site. If you are looking for a web developer with 15+ years of experience, holla at me!

Be it the good 'ol jQuery, vanilla JS or modern frameworks like Vue and Svelte, front- or backend, I can help you.

Just write me at jobs@jqapi.com :)