Skip to content

Instantly share code, notes, and snippets.

@cardeol
Forked from jimeh/hasOwnProperty.js
Last active August 29, 2015 14:25
Show Gist options
  • Save cardeol/b858bc83a5b94b4dd34b to your computer and use it in GitHub Desktop.
Save cardeol/b858bc83a5b94b4dd34b to your computer and use it in GitHub Desktop.
/*
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]);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment