Some questions about Private Name Objects

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


On Aug 27, 2012, at 16:55 , Matthew Robb <matthewwrobb at gmail.com> 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, ES.next 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 rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120827/0693c793/attachment.html>


More information about the es-discuss mailing list