Some questions about Private Name Objects

Axel Rauschmayer axel at
Mon Aug 27 08:03:29 PDT 2012

On Aug 27, 2012, at 16:55 , Matthew Robb <matthewwrobb at> wrote:

> SO it has to be constructed via new Name() or will it automatically create Name objects when it encounters an assignment of that form? If you do have to create it does that mean in order to access it at all you would need to be in scope of myname2?
> My question I think boils down to whether access is SCOPE gated or OBJECT gated:
> var myClass = (function(){
>   class myClass {
>     constructor(){
>       this[test] = 0;
>     }
>   }
>   return myClass;
> })()
> myClass.prototype.getTest = function() {  return this[test]  }
> Is the above perfectly valid?

No, would complain about the undeclared variable `test` (variable scope, not object). The closest you can get to simulating is by using strings with UUIDs. That avoids the name clashes, but doesn’t hide the properties.

Dr. Axel Rauschmayer
axel at


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list