您的位置:首页 > Web前端 > JavaScript

JavaScript一个继承类的例子

2017-02-24 18:07 393 查看
function Animal(name)
{
this.name = name || "xxx";
this.type = "animal";
}

Animal.prototype = {
say : function(){
alert("I'm a " + this.type + ", my name is " + this.name)
}
}

function Bird(name)
{
Animal.call(this, name);
}

Bird.prototype={
}

var myBird = new Bird("xiaocui");
alert(myBird.type);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  javascript