Skip to content
Discussion options

You must be logged in to vote

상속된다!

// 증명 코드

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!

Replies: 1 comment

Comment options

lim-jiwoo
Nov 2, 2022
Maintainer Author

You must be logged in to vote
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
Labels
None yet
1 participant