Skip to content

Instantly share code, notes, and snippets.

@paranoidjk
Forked from jimeh/hasOwnProperty.js
Created September 1, 2016 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paranoidjk/eb54e8622b3722c65ec792496b5386c6 to your computer and use it in GitHub Desktop.
Save paranoidjk/eb54e8622b3722c65ec792496b5386c6 to your computer and use it in GitHub Desktop.
Cross-browser hasOwnProperty solution
/*
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 = this.__proto__ || this.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