Created
November 8, 2009 09:17
-
-
Save rkatic/229188 to your computer and use it in GitHub Desktop.
jquery.isObject.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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
Ah, my mistake. You're right, overriding the prototype's method would be silly. :P