0
아래 예제와 같이 하나의 masterclass에 여러 클래스의 통계 및 프로토 타입을 병합하려고합니다.es6 클래스 상속
실제로 가능합니까?
Alltogether.dosomething() 또는 Alltogether.o3.myoption1
// class1
class Option1 {
constructor(properties) {
this.o = {};
this.o.myoption1 = properties.o.myoption1;
this.o.myoption2 = properties.o.myoption2;
}
dosomething1() {
return "o1";
}
}
// class2
class Option2 {
constructor(properties) {
this.o2 = {};
this.o2.myoption1 = properties.o2.myoption1;
this.o2.myoption2 = properties.o2.myoption2;
}
dosomething2() {
return "o2";
}
}
// class3
class Option3 {
constructor(properties) {
this.o3 = {};
this.o3.myoption1 = properties.o3.myoption1;
this.o3.myoption2 = properties.o3.myoption2;
}
dosomething3() {
return "o3";
}
}
// now i want to create a super class with the 3 classes above
// however this doesnt work...
class Alltogether extends (Option1, Option2, Option3) {
constructor(properties) {
//........
}
}
// My goal is that im able to merge the statics and prototypes to do things like
// Alltogether.dosomething() // o2
// or Alltogether.o3.myoption1
개체의 요점은 이러한 1,2,3 클래스를 정의 할 필요가 없다는 것입니다. 클래스 정의 Option, 인스턴스 생성 (옵션). AllTogether는 옵션을 확장하여 모든 옵션이 상속하는 프로토 타입 메소드를가집니다. –
질문이 하나뿐입니다. 왜? – christopher