摘要:
使用原型链实现继承,会有一个问题,多个实例共享一个属性。 为了解决这个问题,我们使用构造函数来实现继承。 function A(){ this.people=['name','age',"sex"]; } function B(){ A.call(this); } var x=new B(); x. 阅读全文
摘要:
function A(){ this.name="zhangsan"; } A.prototype.getName=function(){ return this.name; } function B(){ this.age=20; } B.prototype=new A(); //子类型有时候需要 阅读全文