Posts

Showing posts from February, 2021

How does JavaScript .prototype work?

Image
How does JavaScript .prototype work? understanding how prototype working for function Prototype object in function: We can create many instances, all instances will have name and age property but address property will not be there inside instances. It will be there inside  prototype object   so that  address we can access from any instance. function have "prototype" property as hidden property that will point to the prototype object and instance also have "__proto__" property as hidden property that also will be point to the same prototype object.            f.prototype.address === fobj.__proto__.address // this will be true, those are pointing same place   understanding how prototype working for class Prototype object in class: The display method is crated inside the class but it is located inside Prototype object  so we can access the display method from both instances. Lisko substitution principle Lisko substitution...