继承方法-->一级一级继承

Grand.prototype.lastName = 'ji';
function Grand(){};
var grand = new Grand();
Father.prototype = grand;
function Father(){
      this.name = 'hehe';
};
var father = new Father(); Son.prototype = father;
function Son(){ this.name = 'klkx'
}; var son = new Son(); console.log(son);

缺点没有必要的属性也一并继承了

猜你喜欢

转载自www.cnblogs.com/jokes/p/9234400.html