title: How can a JavaScript object refer to values in itself?
body: <p>Lets say I have the following JavaScript:</p>
  <pre><code>var obj = {
   key1 : &quot;it &quot;,
   key2 : key1 + &quot; works!&quot;
  };
  alert(obj.key2);
  </code></pre>
  <p>This errors with &quot;key1 is not defined&quot;. I have tried</p>
  <pre><code>this.key1
  this[key1]
  obj.key1
  obj[key1]
  this[&quot;key1&quot;]
  obj[&quot;key1&quot;]
  </code></pre>
  <p>and they never seem to be defined.</p>
  <p>How can I get key2 to refer to key1's value?</p>