Skip to content

Instantly share code, notes, and snippets.

@VoloshchenkoAl
Created July 14, 2016 11:28
Show Gist options
  • Save VoloshchenkoAl/5708b38c0c640b75f0b8f2382d4ee28f to your computer and use it in GitHub Desktop.
Save VoloshchenkoAl/5708b38c0c640b75f0b8f2382d4ee28f to your computer and use it in GitHub Desktop.
function Animal(voice){
this.voice = voice || 'grunt';
}
Animal.prototype.speak = function(){
console.log(this.voice);
}
function Cat(name, color){
Animal.call(this, 'Meow');
this.name = name;
this.color = color;
}
Cat.prototype = Object.create(Animal.prototype);
var fluffy = new Cat('Fluffy','black');
console.log(fluffy);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment