现在的位置: 首页 > 综合 > 正文

实现方法重载的测试代码

2013年10月05日 ⁄ 综合 ⁄ 共 252字 ⁄ 字号 评论关闭

function Base()
{

}
Base.prototype.a = function()
{
 alert('a in Base');
}

function Derived()
{

}
Derived.prototype = new Base();
Derived.prototype.base = new Base();
Derived.prototype.a = function()
{
 alert('a in Derived');
}

var b = new Base();
b.a();
var c = new Derived();

c.a();
c.base.a();

抱歉!评论已关闭.