复制代码 代码如下: 批量实现面向对象的实例 <BR>window.onload = function(){ <BR>function Person(name,age){ <BR>this.name = name; <BR>this.age = age; <BR>} <BR>Person.prototype.showName = function(){ <BR>alert(this.name); <BR>}; <BR>function extend(parent,child,method){ <BR>function a(){ <BR>parent.apply(this,arguments); <BR>child.apply(this,arguments); <BR>}; <BR>for(var i in parent.prototype){ <BR>a.prototype[i]=parent.prototype[i]; <BR>} <BR>for(var i in method){ <BR>a.prototype[i] = method[i]; <BR>} <BR>return a; <BR>};//参数为父级构造函数,子级构造函数,子级方法 <BR>var int = extend(Person,function(name,age,job){ <BR>this.job = job; <BR>}, <BR>{ <BR>showjob:function(){ <BR>alert(this.job); <BR>} <BR>} <BR>); <BR>var oc=new int('侠客',24,'工作'); <BR>oc.showjob(); <BR>} <BR> 面向对象继承实例 开始展示批量实现面向对象的实例