複製程式碼 代碼如下: 物件導向繼承實例 <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 決定寫一下,其實繼承就是繼承父級的屬性和方法