Skip to content

Instantly share code, notes, and snippets.

@devdays
Created December 2, 2014 21:25
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 devdays/f0fd820242354961cdde to your computer and use it in GitHub Desktop.
Save devdays/f0fd820242354961cdde to your computer and use it in GitHub Desktop.
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