function classA(sscolor){
this.color=sscolor;
this.saycolor=function(){
alert(this.color);
};
}
function classB(scolor,sname){
this.method=classA;
this.method(scolor);
delete this.method;
this.name=sname;
this.sayname=function(){
alert(this.name);
};
}
var obja=new classA("red");
var objb=new classB("blue","coolboy");
obja.saycolor();
objb.saycolor();
objb.sayname();
this.color=sscolor;
this.saycolor=function(){
alert(this.color);
};
}
function classB(scolor,sname){
this.method=classA;
this.method(scolor);
delete this.method;
this.name=sname;
this.sayname=function(){
alert(this.name);
};
}
var obja=new classA("red");
var objb=new classB("blue","coolboy");
obja.saycolor();
objb.saycolor();
objb.sayname();
保存为aaa.htm后用IE打开(前提,机器上至少安装OFFICE)
<script>
function classA(sscolor){
this.color=sscolor;
this.saycolor=function(){
alert(this.color);
};
}
function classB(scolor,sname){
this.method=classA;
this.method(scolor);
delete this.method;
this.name=sname;
this.sayname=function(){
alert(this.name);
};
}
debugger
var obja=new classA("red");
var objb=new classB("blue","coolboy");
obja.saycolor();
objb.saycolor();
objb.sayname();
</script>
this.method=classA;
this.method(scolor);
delete this.method;
this.method(scolor);=>给这个方法赋值,其实就是给classA传一个参数
delete this.method;=>删除这个this.method成员
this.method(scolor);=>执行method方法
delete this.method;=>删除这个this.method成员