Skip to content

Instantly share code, notes, and snippets.

@DTrejo
Created February 14, 2012 23:47
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 DTrejo/1831741 to your computer and use it in GitHub Desktop.
Save DTrejo/1831741 to your computer and use it in GitHub Desktop.
dog and cat and animal
function Animal() {
this.legs = 4;
};
function Dog() {
this.sound = 'woof';
};
Dog.prototype = new Animal();
function Cat() {
this.sound = 'meow';
};
Cat.prototype = new Animal();
var d = new Dog();
console.log(d);
console.log(d.sound);
console.log(d.legs);
var c = new Cat();
console.log(c);
console.log(c.sound);
console.log(c.legs);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment