Created
March 5, 2017 01:59
-
-
Save rockstarartist/1c6d34d3e649a78c398dba28c0410667 to your computer and use it in GitHub Desktop.
JavaScript Prototype and hasOwnProperty test
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 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