Created
March 15, 2010 00:02
-
-
Save jimeh/332357 to your computer and use it in GitHub Desktop.
Cross-browser hasOwnProperty solution
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
/* | |
Cross-browser hasOwnProperty solution, based on answers from: | |
http://stackoverflow.com/questions/135448/how-do-i-check-to-see-if-an-object-has-an-attribute-in-javascript | |
*/ | |
if ( !Object.prototype.hasOwnProperty ) { | |
Object.prototype.hasOwnProperty = function(prop) { | |
var proto = obj.__proto__ || obj.constructor.prototype; | |
return (prop in this) && (!(prop in proto) || proto[prop] !== this[prop]); | |
}; | |
} |
obj
needs to be changed to this
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what is obj?