How do you use super keyword with an example?

The `super` keyword in JavaScript is used to access and call functions on an object's parent. It is often used in constructors and methods of derived classes to call the constructor or methods of the superclass.
super, JavaScript, inheritance, parent class, derived class
class Animal { constructor(name) { this.name = name; } speak() { return `${this.name} makes a noise.`; } } class Dog extends Animal { constructor(name) { super(name); // Call the constructor of the parent class } speak() { return `${this.name} barks.`; } } const dog = new Dog('Rex'); console.log(dog.speak()); // Outputs: 'Rex barks.'

super JavaScript inheritance parent class derived class