类的继承

//父类
function Person(){
    this.money=1000  
}

  

1.原型链继承

function Sam(){}
Sam.prototype = new Person();
Sam.prototype.address ='中国';

  

2.构造继承

function Sam(){
    Person.call(this)
    this.address='中国'
}

  

3.实例继承

function Sam(){
    var instants = new Person()
    instants.address='中国'    
    return instants
}

  

4.Object.create()方法继承

function Sam (){
   return Object.create(new Person())  
}

  

 

posted @ 2017-09-27 15:46  小结巴巴吧  阅读(146)  评论(0编辑  收藏  举报