title: How to put Global Variables in a Globals.js module and access them in other modules?
body: <p>I feel silly but I can't find a good example of how to do this.  I've seen some that come close and maybe they are right on target but I can't figure it out.</p>
  
  <ol>
  <li>How do I create a module that contains all my global variables?</li>
  <li>How do I export or import or whatever I need to do to use those global variables in another js module?</li>
  </ol>
  
  <p>I'm creating a small application that contains about 6 variables that must have a global scope to my application.  Can someone please show me an example?</p>
  
  <p>Global variables:</p>
  
  <pre><code>var scene = viewer.scene;
  var ellipsoid = scene.globe.ellipsoid;
  var entity;
  var newPolygon;
  var newOutline;
  var canvas = document.getElementById("canvas");
  var gl = canvas.getContext("webgl");
  var extensions = gl.getSupportedExtensions();
  </code></pre>
  
  <p>I have the above in a file called globals.js</p>
  
  <pre><code>    &lt;script src="Source/globals.js"&gt;&lt;/script&gt;
      &lt;script src="Source/index.js"&gt;&lt;/script&gt;
      &lt;script src="Source/positionHandler.js"&gt;&lt;/script&gt;
      &lt;script src="Source/polyCreate.js"&gt;&lt;/script&gt;
      &lt;script src="Source/polyUpdate.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>It is listed in the html file.  All appears to work just fine but there is a browser level variable that thinks it's false.  So now I want to be sure global variables are accessible as expected. </p>
  
  <pre><code>Globals = {
    scene:       require('scene'),
    ellipsoid:   require('ellipsoid'),
    canvas:      require('canvas')
  };
  module.exports = Common;
  </code></pre>
  
  <p>or </p>
  
  <pre><code>Globals = {
    scene:       require('viewer.scene'),
    ellipsoid:   require('scene.globe.ellipsoid'),
    canvas:      require('document.getElementById("canvas")')
  };
  module.exports = Common;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>Globals = {
      scene      : viewer.scene,
      ellipsoid  : scene.globe.ellipsoid,
      canvas     : document.getElementById("canvas"),
      gl         : canvas.getContext("webgl"),
      extensions : gl.getSupportedExtensions()
  };
  module.exports = Common;
  </code></pre>
  
  <p>I don't get the <strong>require</strong> and how to set it up.</p>