I found out about computed property names here. In the given example, computed property names are used on an object that is subsequently stored as a variable.
When I try to use computed property names in an object that is returned as is, for example from within a map function, I get Uncaught SyntaxError: unexpected token: ':'.
Am I overlooking something or is this simply not possible without storing the object in a variable first.
Here is my code snippet
const values = [['foo1', { value: 1 }], ['foo2', { value: 2 }], ['foo3', { value: 3 }]];
values.map(([key, { value }]) => { [`${value}`]: key });