JavaScript继承之闭包原型继承法
function Dog()
{
this.name = "普通的狗";
this.wow = function()
{
alert(this.name + " is wowing!!");
}
this.sleep = function()
{
alert(this.name + " is sleep");
}
}
function FlyingDog()
{
this.name = "会飞的狗";
this.wow = function()
{
alert(this.name + " is flying and wowing");
}
}
FlyingDog.prototype = new Dog();
flyingdog = new FlyingDog();
flyingdog.wow();
flyingdog.sleep();