This is the behavior defined in the spec:
```js
const key1 = Symbol('description');
const key2 = Symbol();
let obj = {
[key1]() {},
[key2]() {},
};
console.log(obj[key1].name); // '[description]'
console.log(obj[key2].name); // ''
```
I’m wondering: if a symbol has no description,
being a function name I rather wonder if it wouldn't be better to have
`'description'` without square brackets ... to be consistent with the fact
the Symbol has no name.
If that's instead a way specified as such in order to understand that is a
Symbol then I agree, for consistency, it should have
On Thu, Sep 10, 2015 at 11:02 AM, Michael McGlothlin
wrote:
> One issue I did notice with WeakMaps is that because it can't use primative
> values as keys that they'll throw errors unless otherwise handled. Checking
> if they are an instanceof Object and if not using
I would avoid using Object identities on primitives as you can do `===`
comparisons if IDs are serialized and have differing IDs for equivalent
objects.
On Thu, Sep 10, 2015 at 1:02 PM, Michael McGlothlin <
mike.mcgloth...@gmail.com> wrote:
> One issue I did notice with WeakMaps is that because
One issue I did notice with WeakMaps is that because it can't use primative
values as keys that they'll throw errors unless otherwise handled. Checking
if they are an instanceof Object and if not using a Map instead seems to
work.
I wouldn't think using primatives as WeakMap keys would be an
It depends I guess. Should be a configuration option.
On Thu, Sep 10, 2015 at 10:37 AM Waldemar Horwat
wrote:
> This would have interesting consequences if you run your code via a
> minifier. Should the minifier return a string with the old name or the new
> name?
>
>
6 matches
Mail list logo