On Tue, Sep 8, 2015 at 2:07 PM, Mark S. Miller <[email protected]> wrote:
> On Tue, Sep 8, 2015 at 1:57 PM, Michael McGlothlin
> <[email protected]> wrote:
>>
>> I try to keep it pretty simple. It's not fancy but the times you want fast
>> and dirty information like this are the same times you don't want to have to
>> define it manually.
>>
>>  Symbol.identity = Symbol( 'Symbol.identity' );
>>  const identity = Symbol( 'identity' );
>>  var OBJECT_ID = 0;
>>  Object.defineProperty( Object.prototype, Symbol.identity, {
>>   get: () => {
>>    if ( !Object.hasOwnProperty.call( this, identity ) ) {
>>     this[ identity ] = ++OBJECT_ID;
>
>
> Does not work on frozen objects.

Of course, it's trivial to switch it to WeakMap'ing the key.

~TJ
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to