강의

멘토링

커뮤니티

Inflearn Community Q&A

insung9405538's profile image
insung9405538

asked

[Code Factory] [Introduction] Complete Code Factory's Javascript full course in just 9 hours

Super Keyword

Super Keyword 질문 있어요!

Written on

·

324

0

${super.sayHello()} 에서 ${this.sayHello}로 바꿔도 함수가 작동되는데 상속 때문인 가요?

javascript

Answer 1

0

codefactory님의 프로필 이미지
codefactory
Instructor

안녕하세요!

sayHello()와 sayHello의 차이를 말씀하시는게 맞을까요?

전자는 함수를 실행한 상태고 후자는 실행하지 않은 상태입니다.

실행하지 않으면 함수의 정의를 받고 실행하면 함수의 반환 값을 받습니다. (출력해보세요)

감사합니다!

insung9405538님의 프로필 이미지
insung9405538
Questioner

아, 오타가 있었네요..
${super.sayHello()} > ${this.sayHello()} 입니다!

codefactory님의 프로필 이미지
codefactory
Instructor

super.sayHello()는 부모 메서드고 this.sayHello()는 자기 메서드입니다. 만약에 둘이 같은 로직이 있다면 같은 결과를 반환합니다.

insung9405538's profile image
insung9405538

asked

Ask a question