Rick Waldron (2013-07-19T12:41:41.000Z)
These are computed properties and Allen has already added them to the
latest ES6 draft.

ComputedPropertyName :
  [ AssignmentExpression ]

Rick


On Fri, Jul 19, 2013 at 7:09 AM, Jussi Kalliokoski <
jussi.kalliokoski at gmail.com> wrote:

> Hi everyone,
>
> This is almost purely a syntactic sugar proposal, and if there's already a
> proposal like this being/been discussed, please point me that way, I
> couldn't find anything. Anyway, the use case is as follows:
>
> You have keys that come, for example from a config file or are defined as
> constants, and you want to create objects with those keys. What you
> currently have to do is to use a mix of object notation syntax and
> assignment:
>
> myObject = {
>   someKey: 'someValue'
> };
> myObject[MY_KEY_ID] = 'my value';
>
> This is usually ok, but it's a bit confusing to read especially if the
> object is long and you try to find the definition inside the brackets but
> can't. Also, as far as I know, `"someKey"` and `MY_KEY_ID` end up being
> defined differently; I doubt that the latter matters much, but what I have
> in mind would fix both things:
>
> myObject = {
>   someKey: 'someValue',
>   [MY_KEY_ID]: 'my value'
> };
>
> So basically you could use brackets to signify that the key is the value
> of an expression inside the brackets.
>
> Cheers,
> Jussi
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130719/1abdbdf4/attachment.html>
domenic at domenicdenicola.com (2013-07-23T02:43:46.814Z)
These are computed properties and Allen has already added them to the
latest ES6 draft.

```
ComputedPropertyName :
  [ AssignmentExpression ]
```