>
> ```js
> var constructor=function(){
> 'use strict';
> var allObjects=new WeakSet();
> var privateSymbol=Symbol('private', true);
> var ret=function(){
> if(this===undefined)throw Error('Invalid Construction');
> this[privateSymbol]=1;
> allObjects.add(this);
> }
> ret.prototype.set=function(sth){
> if(!allObject.has(this))throw Error('Invalid Call');
> this[privateSymbol]=sth; // Now this can be called safely, no more
> worry about leak to Proxy
> }
> ret.bind(undefined);
> }
> ```
>
One of the goals of any "object-private state" proposal has to be:
- It should be easy to create private-state-carrying abstractions which are
"safe",
- It should be easy to validate such abstractions as "safe".
I think the code above is a great illustration of how private symbols fail
to satisfy these goals.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss