JavaScript 面向对象的程序设计记录笔记5

继承:

  原型链继承

  function SuperType() {

    this.propperty = true;

  }

  Supertype.prototype.getSuperValue = function() {

    return this.propperty;

  }

  function SubType() {

    this.subproperty = false;

  }

  // 继承了SubType 

  SubType.prototype = new SuperType();

  SubType.prototype.getSubValue = function () {

    return this.subproperty;

  }

  var instance = new SubType();

  console.log(instance.getSuperValue()); // true

原文地址:https://www.cnblogs.com/lzj0824/p/6979230.html