// 생성자 함수 SuperType function SuperType() { this.superValue = "Super"; } // SuperType : Prototype에 메서드 정의 SuperType.prototype.getSuperValue = function() { return this.superValue; }; // 생성자 함수 SubType function SubType() { this.subValue = "Sub"; } // 기존 Prototype 연결을 끊고, // SuperType의 Prototype으로부터 객체 생성 하여 연결하여 상속 SubType.prototype = new SuperType(); // new Prototype객체에 메서드 추가 SubType.prototype.getSubValue = function() { return this.subValue; }; // SuperType을 상속받은 SubType Prototype객체로 부터 객체 생성 var instance = new SubType(); document.write(instance.getSuperValue()); // Super document.write("<br>"); document.write(instance.getSubValue()); // Sub