What do you call a set of Javascript closures that share a common context?

Posted by Ed Stauff on Stack Overflow See other posts from Stack Overflow or by Ed Stauff
Published on 2010-06-12T20:04:36Z Indexed on 2010/06/12 20:12 UTC
Read the original article Hit count: 167

Filed under:
|

I've been trying to learn closures (in Javascript), which kind of hurts my brain after way too many years with C# and C++. I think I now have a basic understanding, but one thing bothers me: I've visited lots of websites in this Quest for Knowledge, and nowhere have I seen a word (or even a simple two-word phrase) that means "a set of Javascript closures that share a common execution context". For example:

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've read, this seems to be one common way of implementing data hiding. The value returned by CreateThingy is, of course, an object, but what would you call the set of functions which are properties of that object? Each one is a closure, but I'd like a name I can used to describe (and think about) all of them together as one conceptual entity, and I'd rather use a commonly accepted name than make one up.

Thanks!

-- Ed

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about closures