Jussi Kalliokoski (2013-07-19T11:09:44.000Z)
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130719/1df9609e/attachment.html>
domenic at domenicdenicola.com (2013-07-23T02:43:09.538Z)
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:

```js
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:

```js
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.