title: Using an IIFE and passing in parameters, when should I do it? Javascript
body: <p>Most sections of my library are made up of files that have a structure like so,</p>
  
  <pre><code>myLib.Something = (function() {
  
       function Something() {
  
       }
  
       return Something;
  
  })();
  </code></pre>
  
  <p>Now suppose that inside <code>Something</code> I use <code>document</code> or <code>window</code> so now my file looks like this;</p>
  
  <pre><code>myLib.Something = (function() {
  
       function Something(id) {
  
           this.somethingElse = document.getElementById(id);
       }
  
       return Something;
  
  })();
  </code></pre>
  
  <p>When using document inside <code>Something</code>'s constructor should I pass document into the IIFE, so that it would look like below;</p>
  
  <pre><code>myLib.Something = (function(document) {
  
       function Something(id) {
  
           this.somethingElse = document.getElementById(id);
       }
  
       return Something;
  
  })(document);
  </code></pre>
  
  <p>Or should I only pass in variables to the IIFE when they are used outside of <code>Something</code>? Like below,</p>
  
  <pre><code>myLib.Something = (function(document) {
  
       var document = document;
  
       function Something() {
  
       }
  
       return Something;
  
  })(document);
  </code></pre>