Skip to content

Instantly share code, notes, and snippets.

@mariomarin
Forked from rkatic/jquery.isObject.js
Created August 31, 2011 17:41
Show Gist options
  • Select an option

  • Save mariomarin/1184151 to your computer and use it in GitHub Desktop.

Select an option

Save mariomarin/1184151 to your computer and use it in GitHub Desktop.
jquery.isObject.js
(function(jQuery){
var toString = Object.prototype.toString,
hasOwnProp = Object.prototype.hasOwnProperty;
jQuery.isObject = function( obj ) {
if ( toString.call(obj) !== "[object Object]" )
return false;
//own properties are iterated firstly,
//so to speed up, we can test last one if it is not own
var key;
for ( key in obj ) {}
return !key || hasOwnProp.call( obj, key );
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment