title: How could I restrict access between javascript files included in a webpage?
body: <p>I have been learning about encapsulation in Javascript with the <a href="https://medium.com/@tkssharma/javascript-module-pattern-b4b5012ada9f" rel="nofollow noreferrer">module pattern</a>. I want to give access to specific js files. From what I understand, it is only possible to restrict access to everything and give access to everything, is this correct?</p>
  
  <p><em>smiley.js</em></p>
  
  <pre><code>(function(exports){
      function smiley(string){
          return string + ' :)';
      };
      exports.smiley = smiley;
  })(this);
  </code></pre>
  
  <p><em>play.js</em></p>
  
  <pre><code>smiley('Hello');
  </code></pre>
  
  <p>Given an HTML file that includes smiley.js and play.js.</p>
  
  <pre><code>&lt;script src='smiley.js'&gt;&lt;/script&gt;
  &lt;script src='play.js'&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Is it possible to have another js file that does not have access to smiley.js but is also included in the HTML file?</p>
  
  <p>Is there only global (window) scope and private scope or can I specify a scope for different files?</p>