Say I have a Javascript class defined and instantiated like this:
Demo = function() {
var abc = "foo";
return {
get test() { return abc; }
}
}
obj = Demo();
obj.test // evaluates to "foo"
Confronted only with this Demo instance obj, can I change the value of the variable abc belonging to this object, that was defined in the closure introduced by the constructur function?
var abcis NOT directly available outside the scope of Demo.If you want to change it from outside that scope, you have to add a method to set it.
See this previous discussion for examples of the types of accessors you could use.