复制代码 代码如下: 面向对象继承实例 <BR>window.onload = function(){ <BR>function parent(age,name){ <BR>this.age = age; <BR>this.name = name; <BR>} <BR>parent.prototype.show = function(){ <BR>alert('父级方法'); <BR>} <BR>function child(age,name,job){ <BR>parent.apply(this,arguments); <BR>this.job = job; <BR>} <BR>(function(){ <BR>for(var i in parent.prototype){ <BR>child.prototype[i]=parent.prototype[i] <BR>} <BR>})(); <br><br>var b = new parent(14,'侠客行'); <BR>var a = new child(15,'狼侠','侠客'); <BR>a.show(); <br><br>} <BR> 面向对象继承实例 经常看到面试题有关继承问题 a如何继承b 决定写一下,其实继承就是继承父级的属性和方法