super() फ़ंक्शन
पैरेंट क्लास के कंस्ट्रक्टर को कॉल करने और किसी ऑब्जेक्ट के पैरेंट क्लास पर फ़ंक्शन्स को एक्सेस करने के लिए 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>