Skip to content

Instantly share code, notes, and snippets.

@rkatic
Created November 8, 2009 09:17
Show Gist options
  • Save rkatic/229188 to your computer and use it in GitHub Desktop.
Save rkatic/229188 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);
@thinkt4nk
Copy link

Ah, my mistake. You're right, overriding the prototype's method would be silly. :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment