js的继承

//A对象

function A(){

  this.abc = 12;

}

A.prototype.show = function(){

  alert(this.abc);

}

//B对象继承A

function B(){      

  //this  -> new B()   继承父级属性

  A.call(this);

}

 //方法的继承

for(var i in A.prototype){

  B.prototype[i] = Aprototype[i];

}

B.prototype.fn = function(){

  alert('abc');

}

var objB = new B();

var objA = new A();

objA.fn();   //报错  对象A 没有这个方法

原文地址:https://www.cnblogs.com/z-sheng/p/4500932.html