Flykye.前端历程

front-end..

导航

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();

posted on 2008-10-05 02:21  flykye  阅读(241)  评论(0编辑  收藏  举报