title: What's the difference between a global variable and a 'window.variable' in JavaScript?
body: <p>I'm reading the <a href="https://en.wikipedia.org/wiki/Backbone.js" rel="nofollow noreferrer">Backbone.js</a> documents and am seeing a lot of code that assigns attributes to the <em>window</em> object:</p>
  <pre><code>window.something = &quot;whatever&quot;;
  </code></pre>
  <p>What's the difference between calling this code, and just assigning the variable and creating a global variable, like this:</p>
  <pre><code>something = &quot;whatever&quot;;
  </code></pre>
  <p>I assume there is some kind of scope difference, and/or object ownership difference (<em>window</em> being the owner vs. not), but I am interested in the detail between the two and why I would use <em>window</em> vs. not use it.</p>