In javascript is it possible for a child class to access & change a base class variable? If not is there a way to create a privileged variable? I know you can create privileged functions but what about privileged variables?
Here’s my attempt:
function BaseClass()
{
var privateMap = {"type": "BaseClass"};
}
function ChildClass()
{
// How can I access BaseClass's private variable privateMap?
privateMap["type"] = "ChildClass";
}
ChildClass.prototype = new BaseClass();
ChildClass.prototype.constructor = ChildClass;
1 Answer