Wednesday, September 8, 2021

Inheritance in javascript

 


javascript is a prototype based programming language that means inheritance is possible by using prototype.Every object has this prototype property .

How Inheritance works behind the scene?

Every js object has a prototype property .If any object want to inherit the property /method then these method and property will store in prototype property .Here the person prototype  property is the prototype of john .



By default person constructor's  biggest constructor is object.
In this fig person object can inherit the prototype of object and john can access the property of person prototype and object prototype.

No comments:

Post a Comment

Abstract factory pattern

When single task can be done by multiple groups/family of objects and decision is taken at the runtime.