Skip to content

Instantly share code, notes, and snippets.

@rockstarartist
Created March 5, 2017 01:59
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 rockstarartist/1c6d34d3e649a78c398dba28c0410667 to your computer and use it in GitHub Desktop.
Save rockstarartist/1c6d34d3e649a78c398dba28c0410667 to your computer and use it in GitHub Desktop.
JavaScript Prototype and hasOwnProperty test
function A() {
this.x = "I'm an own property";
}
A.prototype.y = "I'm not an own property";
var instance = new A();
console.log(instance.hasOwnProperty("x")); // true
console.log(instance.hasOwnProperty("y")); // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment