function Animal(name){
this.name = name;
}
Animal.prototype.getName = function() {
return this.name;
};
function Cat(name) {
Animal.apply(this, arguments);
}
Cat.prototype = Object.create(Animal.prototype);
Cat.prototype.constructor = Cat;
Cat.prototype.meow = function() {
return 'Cat ' + this.getName() +' is saying meow';
};
var cat = new Cat('garfield');
alert(cat.getName() === 'garfield'); // true
alert(cat.meow() === 'Cat garfield is saying meow'); // true