The name of a method whose key is a symbol

2015-09-10 Thread Axel Rauschmayer
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,

Re: The name of a method whose key is a symbol

2015-09-10 Thread Andrea Giammarchi
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

Re: Object id, hash, etc?

2015-09-10 Thread Tab Atkins Jr.
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

Re: Object id, hash, etc?

2015-09-10 Thread Bradley Meck
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

Re: Object id, hash, etc?

2015-09-10 Thread Michael McGlothlin
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

Re: What do you think about a C# 6 like nameof() expression for JavaScript.

2015-09-10 Thread Behrang Saeedzadeh
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? > >