Created
December 2, 2014 21:25
-
-
Save devdays/f0fd820242354961cdde to your computer and use it in GitHub Desktop.
Object JavaScript - New Dog
This file contains 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
var spot = new Cat("Spot"); | |
// Cat.prototype is the prototype of spot | |
console.log(Cat.prototype.isPrototypeOf(spot)); | |
// spot inherits the constructor property from Cat.prototype | |
console.log(spot.constructor == Cat.prototype.constructor); | |
console.log(spot.constructor == Cat); | |
// But constructor property doesn’t belong to spot. The line below displays "false" | |
alert(spot.hasOwnProperty("constructor")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment