super()
2024년 11월 23일
super키워드(Keyword)는 객체 리터럴(literal) 또는 클래스(class)의 prototype 속성에 접근하거나 슈퍼클래스(부모 클래스)의 생성자(Constructor)를 호출하는 데 사용된다.
super.prop와 super[expr] 표현식은 클래스와 객체 리터럴의 메서드(Method) 정의에서 모두 사용할 수 있다. super(...args) 표현식은 클래스 생성자에서 유효하다.
JavaScript
JavaScriptsuper([arguments]) // 부모 생성자 호출. super.propertyOnParent super[expression]
설명
super 키워드는 "함수 호출"(super(...args)) 또는 "속성 조회"(super.prop와 super[expr])의 두 가지 방법으로 사용할 수 있다.