title: Create an object with same key and value, without duplicating the data
body: <p>In ES6, we can do:</p>
  
  <pre><code>const key = "foo"
  const myObj = { key }
  myObj
  // =&gt; { foo: "foo" }
  </code></pre>
  
  <p>So, <code>{ key }</code> is equivalent with <code>{ key: key }</code>.</p>
  
  <p>But, how can we create the same object without having the <code>key</code> variable?</p>
  
  <p>I want to have something like <code>{ foo: "foo" }</code>. I tried <code>obj = { "foo" }</code>, but that throws.</p>
  
  <p>What's the right way to build this object, without using a variable and without duplicating the <code>foo</code> word?</p>