When you call getA
from any instance, the value of this
inside it will point to the instance itself. You can achieve what you are looking for by changing the installation code:
ParentClass.prototype.setA = function(inp){ ParentClass.prototype.a = inp; }
Note that calling getA
from the getA
instance returns null
, and the constructor defines its own property a
, which obscures it with the prototype.
source share