In ES6, you have "computed property names" (see http://www.ecma-international.org/ecma-262/6.0/):
PropertyName : See 12.2.6
LiteralPropertyName
ComputedPropertyName
LiteralPropertyName : See 12.2.6
IdentifierName
StringLiteral
NumericLiteral
ComputedPropertyName : See 12.2.6
[ AssignmentExpression ]
Which means, when you write [Expression] as the key, instead of a StringLiteral, NumberLiteral or IdentifierName. The expression gets evaluated and used as the key instead.
Like this:
> a=["key", "value"]
["key", "value"]
> o={[a[0]]: a[1], [3*3]: "hello"}
Object {key: "value", 9: "hello"}
Note however, that ES6 still isn't supported everywhere. In the case this feature isn't supported, just assign the values after the object has been created (like in your second example).