title: How to make modular constants in javascript
body: <p>i am a strong believer in encapsulation and this is hard using javascript. I want to be able to use constants that are not defined on a global level, but I am unable to accomplish this
  Example:</p>
  
  <p>html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;body&gt;
   &lt;p&gt;
    &lt;b&gt;some examples&lt;/b&gt;
   &lt;/p&gt;
   &lt;p&gt;
    &lt;script&gt;some.STRING&lt;/script&gt;&lt;br&gt;
    &lt;script&gt;some.ARRAY.join(' - ')&lt;/script&gt;
   &lt;/p&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>javascript</p>
  
  <pre><code>// some.js
  var some = (function () {
          return {
              STRING: 'some string',
              ARRAY: ["some", "data", "in", "an", "array"]
          };
      }
  );
  </code></pre>
  
  <p>I would like the output to contain the two lines below</p>
  
  <pre><code>some string
  some - data - in - an - array
  </code></pre>
  
  <p>jsfiddle: <a href="https://jsfiddle.net/p3kgpx70/4/" rel="nofollow">https://jsfiddle.net/p3kgpx70/4/</a></p>