I'm trying to learn closure (in Javascript), which is why I have been hurting my brain for too long with C # and C ++. I think I now have a basic understanding, but one thing bothers me: I visited many sites in this Knowledge Search, and I havenโt seen a single word (or even a simple two-word phrase) anywhere, which means a Javascript closure set that has a common execution context. " For instance:
function CreateThingy (name, initialValue)
{
var myName = name;
var myValue = initialValue;
var retObj = new Object;
retObj.getName = function () {return myName; }
retObj.getValue = function () {return myValue; }
retObj.setValue = function (newValue) {myValue = newValue; }
return retObj;
};
From what I read, this is apparently one of the common ways to implement data hiding. The value returned by CreateThingy is, of course, an object, but what would you call a set of functions that are properties of this object? Each of them is a closure, but I would like a name that I could use to describe (and think) all together as one conceptual entity, and I would rather use a common name than do this.
Thank!
- Ed
source
share