Javascript super keyword
In JavaScript, the super keyword is used to call methods or access properties of a parent class within a subclass.
When a class extends another class, the subclass can call the constructor and methods of the parent class by using the super keyword.
For example, to call the constructor of the parent class, we can use super() inside the constructor of the subclass. This is useful when we want to inherit properties and behavior from the parent class.
The Car class calls the super keyword in its constructor to call the constructor of the parent Vehicle class and set the make and model properties. It then adds its own year property.
__________________
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|