Below is the sample snippet with extends keyword in TS format.
And, its equivalent JS file as shown below.
Now, let me go ahead and few properties to child class as well. As you can see in the below screenshot, intellisense is telling, there is some problem with constructor here. Let’s fix that first. In order to invoke the child class constructor, we need to make sure that, we will be invoking super class constructor here as well, which is Employee here. Below snippet is the modified snippet.
Let me go ahead and put the finished code here,
And, equivalent JS code,
With the above change in place, when I go ahead and run the app, it will produce the desired output as shown below. I hope, you would have liked this discussion. In coming section, we will delve more into it.Till then, stay tuned and Happy Coding. Thanks, Rahul Sahay Happy Coding
808 total views, 2 views today