프로그래밍(Web)/업무관련
[바미] 서로가 서로를 필요로 할 때
Bami
2022. 4. 8. 12:22
728x90
반응형
728x170
class ExamClass {
constructor() {
...
this.init();
}
init() {
this.A = new constructorA(this.B);
this.B = new constructorB(this.A);
this.C = new constructorC(this.A, this.B);
}
}
위처럼 A는 A를 생성하기 위해 B가 필요하고, B는 B를 생성하기 위해 A가 필요하는 상황이였습니다.
그 때는 ExamClass를 사용하여 해결하였습니다.
class ExamClass {
constructor() {
...
this.init();
}
init() {
this.A = new constructorA(this);
this.B = new constructorB(this.A);
this.C = new constructorC(this.A, this.B);
}
}728x90
반응형
그리드형