js实现继承的五种方式

function Parent(firstname)  
{  
    this.fname=firstname;  
    this.age=40;  
    this.sayAge=function()  
    {  
        console.log(this.age);  
    }  
}  
function Child(firstname)  
{  
    this.parent=Parent;  
    this.parent(firstname);  
    delete this.parent;  
    this.saySomeThing=function()  
    {  
        console.log(this.fname);  
        this.sayAge();  
    }  
}  
var mychild=new  Child("");  
mychild.saySomeThing();  
function Parent(firstname)  
{  
    this.fname=firstname;  
    this.age=40;  
    this.sayAge=function()  
    {  
        console.log(this.age);  
    }  
}  
function Child(firstname)  
{  
  
    this.saySomeThing=function()  
    {  
        console.log(this.fname);  
        this.sayAge();  
    }  
   this.getName=function()  
   {  
       return firstname;  
   }  
  
}  
var child=new Child("");  
Parent.call(child,child.getName());  
child.saySomeThing();  
function Parent(firstname)  
{  
    this.fname=firstname;  
    this.age=40;  
    this.sayAge=function()  
    {  
        console.log(this.age);  
    }  
}  
function Child(firstname)  
{  
  
    this.saySomeThing=function()  
    {  
        console.log(this.fname);  
        this.sayAge();  
    }  
    this.getName=function()  
    {  
        return firstname;  
    }  
  
}  
var child=new Child("");  
Parent.apply(child,[child.getName()]);  
child.saySomeThing();  
function Parent()  
{  
  
    this.sayAge=function()  
    {  
        console.log(this.age);  
    }  
}  
function Child(firstname)  
{  
    this.fname=firstname;  
    this.age=40;  
    this.saySomeThing=function()  
    {  
        console.log(this.fname);  
        this.sayAge();  
    }  
}  
  
Child.prototype=new  Parent();  
var child=new Child("");  
child.saySomeThing();  
function Parent()  
{  
  
    this.sayAge=function()  
    {  
        console.log(this.age);  
    }  
}  
  
Parent.prototype.sayParent=function()  
{  
   alert("this is parentmethod!!!");  
}  
  
function Child(firstname)  
{  
    Parent.call(this);  
    this.fname=firstname;  
    this.age=40;  
    this.saySomeThing=function()  
    {  
        console.log(this.fname);  
        this.sayAge();  
    }  
}  
  
Child.prototype=new  Parent();  
var child=new Child("");  
child.saySomeThing();  
child.sayParent();