Inheritance in JavaScript is quite different from the concept of inheritance in other languages. It would be right to call it as delegation.Why delegation ?? Because during inheritance in JavaScript, properties and methods from parent class doesn't gets copied to the child class, instead they are linked together via prototypal chain. So, it is also known as prototypal inheritance.https://medium.com/media/18214d8333adbb5668f31791a3202b60/hrefSo let's get started with this.Before that make sure you know about basics of JavaScript Objects .Prerequisites for this lesson:PrerequisitesSo how does inheritance works in JS. Let's understand this with the help of an example.working of inheritanceObjective:We want Teacher and Student to share some generic features from Person and then create object instance from those child classes.As you can see, we have a parent class (or constructor function in JS) called Person which have some properties and methods of its own. Now when we create any child object like - Teacher and Student in our case, we want them to have the access of all the properties and methods available on the parent class.


I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


This article is related to


javascript,object-oriented