日期:2014-05-16 浏览次数:20542 次
function father (sex,name){
    this.name=name;
    this.sex=sex;
    this.hao=function (){
        alert(this.sex+","+this.name );
    }
}
function child (sex,name,age){
    this.method=father; //使FATHER成为自己的方法
    // 使NAME成为自己的属性
    //this.method(name);
    //this.method(sex);
    this.method(sex,name);
    delete this.method;
    this.age=age;
    this.good=function () {
        alert(this.age);
    }
}
var fa=new father("man","he");
var ch=new child("woman","wei","26");
fa.hao();
ch.hao();
ch.good();
------解决方案--------------------
伪继承是吧
this.method=father;
// 下面两行错了 你这样写 只相当于给father传递了一个参数sex  
this.method(name);
this.method(sex);
看到没你的函数: function father (sex,name)
this.method(sex , name)
建议你用apply或者call方法