日期:2014-05-16 浏览次数:20360 次
A=function() { this.code="001"; this.name="whiteangell"; this.getCode=function() { return this.code; } this.getName=function() { return this.name } }; B = function() { this.newMethod=A; this.newMethod(); this.age=20; this.getAge=function() { return this.age; } }; var bb = new B(); alert(bb.getName());
A=function() { this.code="001"; this.name="whiteangell"; this.getCode=function() { return this.code; } this.getName=function() { return this.name } }; B = function() { this.age=20; this.getAge=function() { return this.age; } }; B.prototype=new A(); var bb = new B(); alert(bb.getName());
Object.extend = function(destination,source) { for ( pro in source ) { destination [pro] = source [pro]; } return destination ; }; A = function(){}; A.prototype = { code:"001", name:"whiteangell", getCode:function() { return this.code; }, getName:function() { return this.name } }; B= function(){}; B.prototype= Object.extend({ age:20, getAge:function() { return this.age; } },A.prototype); var bb = new B(); alert(bb.getName());
A=function() { this.code="001"; this.name="whiteangell"; this.getCode=function() { return this.code; } this.getName=function() { return this.name } }; B = function() { A.call(this); this.age=20; this.getAge=function() { return this.age; } }; var bb = new B(); alert(bb.getName());
A=function() { this.code="001"; this.name="whiteangell"; this.getCode=function() { return this.code; } this.getName=function() { return this.name } }; B = function() { A.apply(this); this.age=20; this.getAge=function() { return this.age; } }; var bb = new B(); alert(bb.getName());