对继承的总结

用call和apply只能继承对象的属性不能继承其对象原型链上的方法

  function Cat(name,color){

    Animal.apply(this, arguments);

    this.name = name;

    this.color = color;

  }

  var cat1 = new Cat("大毛","黄色");

  alert(cat1.species); // 动物

 

 

 

用new 方法可以继承原型链和对象自身属性和方法

 

  

 

posted on 2016-12-04 20:01  1883808  阅读(81)  评论(0编辑  收藏  举报