prototype
below 2 ways can define a class.
{member:value}
function(){this.member=value}
functionSon.prototype=functionFather.prototype;
e.g
<script> var bbs={ name : "java", version: "2.0", sayHello:function(){alert(this.version);} } var fna=function(){ this.name="aaa"; this.rate=11; this.ccc=bbs; }; var fnb=new fna(); alert(fnb.ccc.name); var fnc=function(){}; fnc.prototype={ name:"ccc", rate:222 }以下可以实现继承 var fnd=function(){ this.k='11k'; }; fnd.prototype=fnc.prototype;
var dc=new fnd(); alert(dc.name); alert(dc.k);
我们页面跳出ccc(dc.name),和 11k(dc.k ), 说明fnd集成的fnc的name,并且有了自己的扩展k