라벨이 ES6인 게시물 표시
JavaScript Class 상속하는 방법 ES5 Class 상속 // 기본 클래스 function CalcAdd(options) { // this.title = options && options.title || 'Calc Add'; this.calculate = () => { console.log(this.constructor.name, "!!!!!"); }; } CalcAdd.create = function (options) { return new CalcAdd(options); }; // 프로토타입 CalcAdd.prototype.add = function add() { // }; // 상속받은 클래스 function CalcAddWithDivide(options) { // const _this = CalcAdd.apply(this, { title: 'Calc Add With Divide' }) || this; // super(arguments); 와 동일 _this.calculate = function() { console.log(this.constructor.name, "~~~~~~"); }; return _this; }; CalcAddWithDivide.prototype = Object.create(CalcAdd.prototype, { constructor: { value: CalcAdd, enumerable: true, writable: true, configurable: true } }); CalcAddWithDivide.prototype.constructor = CalcAddWithDivide; // 추가 프로토타입 CalcAddWithDivide.prototype.divide = function divide() { // }; ES...