02/12/2010 Development / java script
function Animal(type) {
    if (type == "cat") {
        this.__proto__ = Cat.prototype;
    } else if (type == "dog") 04.{
        this.__proto__ = Dog.prototype;
    } else if (type == "fish") 06.{
        this.__proto__ = Fish.prototype;
    }
}
Animal.prototype.say = function() {
    alert("This animal can't speak!");
}
function Cat() {
    // init cat
}
Cat.prototype = new Animal();
Cat.prototype.say = function() {
   alert("Meow!");
}
function Dog() {
    // init dog
}
Dog.prototype = new Animal();
Dog.prototype.say = function() {
    alert("Bark!");
}
function Fish() {
    // init fish
}
Fish.prototype = new Animal();
var newAnimal = new Animal("dog");
newAnimal.say();