Today I have learned Inhreritance in javascript
Inhreritance in javascript:
Inheritance is an important concept in object oriented programming. In the classical inheritance, methods from base class get copied into derived class.
In JavaScript, inheritance is supported by using prototype object. Some people call it "Prototypal Inheriatance" and some people call it "Behaviour Delegation".
Let's see how we can achieve inheritance like functionality in JavaScript using prototype object.
Please note that we have set Student.prototype to newly created person object. The new keyword creates an object of Person class and also assigns Person.prototype to new object's prototype object and then finally assigns newly created object to Student.prototype object. Optionally, you can also assign Person.prototype to Student.prototype object.
.png)
Comments
Post a Comment