您的位置:首页 > Web前端 > JavaScript

JS 继承实例分析

2008-11-04 00:00 661 查看
function P(name){ 
this.name=name; 

this.p1=function(){ 
alert('Parent Constructor'); 
} 
return this; 
} 
function C(name,id){ 
//this.method=P; 
//this.method(name); //1st method 
//P.call(this,name); //2nd method 
P.apply(this,new Array(name));//3rd method 
this.id=id; 
this.dis=function(){ 
alert(this.name); 
} 
} 
function dis(){ 
alert(this.name); 
} 
function t(){ 
var cc=new C('N','Id'); 
cc.dis(); 
cc.p1(); 
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: