Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Object JavaScript - New Dog
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