Posted on 2007-05-18 14:15
sunbaby 阅读(143)
评论(0) 编辑 收藏 所属分类:
其它
<script>
//类的继承-海浪版
Function.prototype.extend = function (parentClass)
{
var Bs = new Function();
Bs.prototype = parentClass.prototype;
this.prototype = new Bs();
this.prototype.Super = parentClass;
this.prototype.constructor = this;
}
//==============================================
function ClassA()
{
this.a=[9,8,7];
}
ClassB.extend(ClassA);//ClassB继承ClassA
function ClassB()
{
this.Super();//显示调用父类的构造函数
this.b=function(){alert();};
}
var objB1=new ClassB();
var objB2=new ClassB();
objB1.a.push(1,2,3);
alert(objB1.a);
alert(objB2.a);
</script>