<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > < html xmlns ="http://www.w3.org/1999/xhtml" > < head > < title > inherit继承 </ title > < script language ="jscript" type ="text/jscript" > ... Function.prototype.inherit=function(Super)...{ for(var e in Super.prototype)...{ if(!this.prototype[e]) this.prototype[e]=Super.prototype[e]; } Super.call(this); } var A=function()...{ this.f1=function()...{throw new Error("Can not run me!")}; this.f2=function()...{alert("f2");}; } A.prototype.f3=function()...{alert("f3");}; var B=function()...{A.call(this);}; B.inherit(A); var b=new B(); var a=new A(); try...{ alert(b.f1()); }catch( e)...{ alert(e.description); } b.f2(); b.f3(); </ script > </ head > < body > </ body > </ html >