-
|
믹스인도 상속되나? |
Beta Was this translation helpful? Give feedback.
Answered by
lim-jiwoo
Nov 2, 2022
Replies: 1 comment
-
|
상속된다! // 증명 코드
let sayHiMixin = {
sayHi() {
alert(`Hello ${this.name}`);
}
};
class User {
constructor(name) {
this.name = name;
}
}
Object.assign(User.prototype, sayHiMixin);
new User("Dude").sayHi(); // User는 sayHi 호출 가능 - Hello Dude!
class Me extends User { }
new Me('Me').sayHi(); // 상속받은 Me도 sayHi 호출 가능 - Hello Me! |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
lim-jiwoo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
상속된다!