Oops, I forget the WeakSet. So seems my private symbol proposal can work now.
Under very deliberately design, private symbol can be used as private field.
```jsvar 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);}```
On Sun, 21 Dec 2014 12:30:46 +0100, Michal Wadas <[email protected]> wrote:
>> But this is not the core of the problem. The problem is the Proxy introduced
>> in ES6 enables an object to capture and override almost any operation on an
>> object. Without operation on object, it becomes very costly (by using an
>> Array of created objects and compare each of them) to identify whether a
>> object is faked or valid.
>ES6 WeakSet provides you O(1) object check and don't cause memory leak.
> _______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss