脚本毕竟是脚本,但你可以把类的function定义看成是一个构造。
function aa(s)
{
this.value = s;
}
aa.prototype.toString=function()
{
return this.value
}var e = new aa("meizz");
alert(e);
function aa(s)
{
this.value = s;
}
aa.prototype.toString=function()
{
return this.value
}var e = new aa("meizz");
alert(e);
{
return this.value
}这个方法实际上相当与类中的 override ??
{
this.value = s;
this.toString=function()
{
return "form obj.toString() = "+ this.value
}
}
function bb(){}
bb.prototype=new aa();var e = new bb();
e.value = "meizz"; //属性及方法都是继承于aa类
alert(e.toString());