If you want an object obj with a property of hello and a value of world, you can do this:

const obj = {
  hello: 'world';
};

If the property name hello is determined elsewhere, you can do this:

// Pretend this 'hello' gets determined abroad
const propName = 'hello';

const obj = {};
obj[propName] = 'world';

This is a bit verbose, however. A more succinct way is this:

const propName = 'hello';
const obj = {
  [propName]: 'world'
};

It seems simple enough, but I only recently grasped that this syntax is possible. You might think that reducing two statements into one isn’t that much of a gain, but it becomes incredibly useful with CSS Modules in Vue:

<p :class="{ [$style.red]: isRed }">
  Am I red?
</p>

This class expression wouldn’t be possible without this feature.