The name of a method whose key is a symbol

Axel Rauschmayer rauschma at icloud.com
Thu Sep 10 08:38:20 UTC 2015


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, wouldn’t it be better to give the method the name `'[]'` instead of the empty string?

-- 
Dr. Axel Rauschmayer
axel at rauschma.de <mailto:axel at rauschma.de>
rauschma.de

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150910/e81c1f36/attachment.html>


More information about the es-discuss mailing list