title: shortcut to existentially define variable in javascript
body: <p>To avoid clobbering existing variables, I have code like this</p>
  
  <pre><code>window.x = typeof x != "undefined" ? x : {}
  </code></pre>
  
  <p>Which seems like a very long winded way to define something, but necessary to avoid console errors.</p>
  
  <p>I tried this out instead, and it seems to work ok. Is it ok to define a variable like this?</p>
  
  <pre><code>window.x=window.x||{}
  </code></pre>
  
  <p>Or even in the global scope...</p>
  
  <pre><code>x=this.x||{}
  </code></pre>