super() 함수를 사용하여 상위 클래스의 생성자를 호출하고 개체의 상위 클래스에 있는 함수에 액세스합니다.
예
다음 코드를 실행하여 super()를 구현할 수 있습니다.
라이브 데모
<!DOCTYPE html>
<html>
<body>
<script>
class Department {
constructor() {}
static msg() {
return 'Hello';
}
}
class Employee extends Department {
constructor() {}
static displayMsg() {
return super.msg() + ' World!';
}
}
document.write(Employee.displayMsg());
</script>
</body>
</html>