SO fiddle
Test Fiddle mainly for SO Questions
by Nick Craver
JavaScript
jQuery.extend({
isPlainObject: function( obj ) {
var result = !obj || Object.prototype.toString.call(obj) !== "[object Object]" || obj.nodeType || obj.setInterval; if(result) {
return false;
}
result = obj.constructor && !Object.prototype.hasOwnProperty.call(obj, "constructor")
&& !Object.prototype.hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf"); if (result) {
return false;
}
// Own properties are enumerated firstly, so to speed up,
// if last one is own, then all properties are own.
var key;
for ( key in obj ) { $(document.body).append(key + '<br />'); }
alert('Last Property: ' + key);
return key === undefined || Object.prototype.hasOwnProperty.call( obj, key );
}
});
alert($.isPlainObject($(document.body)));