title: Define multiple instances of Module (pattern) in JavaScript
body: <p>I am trying to find best way how to create multiple instances and configure my module according <code>Module</code> pattern. </p>
  
  <p>Currently I have </p>
  
  <pre><code>var Logger = (function () {
      // Private members
      var _settings = {
          json: JSON,
          output: console
      };
      // Private methods
      var _log = function (info) {
          _settings.output.log(info);
      };
      var _dump = function (info) {
          _log(_settings.json.stringify(info));
      };
      // Change default settings
      var changeSettings = function (settingsArgs) {
          if (settingsArgs !== undefined) {
              if (settingsArgs.json !== undefined) {
                  _settings.json = settingsArgs.json;
              }
              if (settingsArgs.output !== undefined) {
                  _settings.output = settingsArgs.output;
              }
          }
      };
      return {
          init: changeSettings,
          log: _log,
          dump: _dump
      };
  })();
  </code></pre>
  
  <p>I have several questions about this pattern.    </p>
  
  <ol>
  <li><p>What is the best way to provide configuration to the module, I simply created setter for private settings fields, but I feel this is not the best way it can be implemented. Please suggest right approach.</p></li>
  <li><p>How to create multiple instances of my module. As I understood, module commonly used to encapsulate global objects and logic (like singletons), so most of time only one instances of module exists, but I need to have multiple instances. In my case this can be useful for example, I can create one logger <code>ConsoleLogger</code> another one will be <code>AlertLogger</code> the difference is output, but now I can only have one instance.   </p></li>
  </ol>
  
  <p>Please suggest the right way to follow, I have already read a lot of articles but haven't found answers to my questions. Thanks</p>