title: Nodejs: Wrapping entire script in a function call
body: <p>I have been writing modules in nodejs as following :</p>
  
  <pre><code>module.exports = function (logger, db, external,constants) {
  
          return {
             //something
  
          }
      }
  </code></pre>
  
  <p>Recently someone in my team suggested that whole script should be wrapped in a function to avoid global confusion of variables i.e. like this : </p>
  
  <pre><code>(function () {
      'use strict';
      module.exports = function (logger, db, external,constants) {
  
          return {
                 //something
          }
      }
  
  }());
  </code></pre>
  
  <p>I understand that this practice is generally used at client side code. But during server side in nodejs is this required? I think that in nodejs there is really no global scope and only module.exports is the one which is accessible really irrespective of whatever we write in script file (ofcourse don't go wild over here).</p>