原型链

来源:互联网 发布:matlab数据预处理 编辑:程序博客网 时间:2024/05/01 01:00
function SuperType(){        this.property = true;    }    SuperType.prototype.getSuperValue = function() {        return this.property;    }    //继承     SubType.prototype = new SuperType();    SuperType.prototype = new SubType();     function SubType() {        this.subproperty = false;    }    SuperType.prototype = new SubType();    SubType.prototype.getSubValue = function() {        return this.subproperty;    }    var o = new SubType();    console.log(o.getSubValue());    console.log(o.getSuperValue());    var a = new SuperType();    console.log(a.getSubValue());    console.log(a.getSuperValue());