日期:2014-05-16 浏览次数:20372 次
function ClassA(sColor){ this.color = sColor; this.sayColor = function(){ alert(this.color); }; } function ClassB(sColor){ this.newMethod = ClassA; this.newMethod(sColor); delete this.newMethod; }
function ClassB(sColor,sName){ ClassA.call(this,sColor); this.name = sName; this.sayName = function (){ alert(this.name); }; }
function ClassB(sColor,sName){ ClassA.apply(this, new Array(sColor)); this.name = sName; this.sayName = function(){ alert (this.name); } }
function ClassA(){} ClassA.prototype.color = "red"; ClassA.prototype.sayColor = function(){ alert(this.color); }; function ClassB(){} ClassB.prototype = new ClassA(); ClassB.name = ""; ClassB.prototype.sayName = function (){ alert(this.name); }
function ClassA(sColor){ this.color = sColor; } ClassA.prototype.sayColor = function(){ alert(this.color); } function ClassB(sColor,sName){ ClassA.call(this,sColor); this.name = sName; } ClassB.prototype = new ClassA(); ClassB.prototype.sayName = function(){ alert(this.name); }
function ClassA(sColor){ this.color = sColor; if(typeof ClassA._initialized == "undefined"){ ClassA.prototype.sayColor = function(){ alert(this.color); } ClassA._initialized = true; } } function ClassB(sColor,sName){ ClassA.call(this,sColor); this.name = sName; if(typeof ClassB._initialized == "undefined"){ ClassB.prototype.inheritFrom(ClassA); ClassB.prototype.sayName = function(){ alert(this.name); } ClassB._initialized = true; } }