title: What is the correct way to define global variable in ES6 modules?
body: <p>I can't seem to find a description of the way I should export global variable from ES6 module. Is there a resource where it's defined?</p>
  
  <p>The only solution that seems to work is referencing a global object, like <code>window</code>:</p>
  
  <pre><code>window['v'] = 3;
  </code></pre>
  
  <p>But what if this scripts runs in Node.js? Then I don't have <code>window</code>; I have <code>global</code>. But this code is not good:</p>
  
  <pre><code>var g = window || global;
  g['v'] = 3;
  </code></pre>
  
  <p>I understand the concept of modules and <strong>don't use globals in my applications</strong>. However, having global variables during debugging in the console may be beneficial, especially when using bundlers like Webpack instead of loaders like SystemJs where you can easily import a module in a console.</p>