title: What is the best way to expose methods from Node.js?
body: <p>Consider I want to expose a method called <code>Print</code></p>
  
  <ol>
  <li>Binding method as <code>prototype</code>:</li>
  </ol>
  
  <p>File Saved as Printer.js</p>
  
  <pre><code>var printerObj = function(isPrinted) {
              this.printed = isPrinted;        
      }
  
  printerObj.prototype.printNow = function(printData) {
          console.log('= Print Started =');
  };
  module.exports = printerObj;
  </code></pre>
  
  <p>Then access <code>printNow()</code> by putting code <code>require('Printer.js').printNow()</code> in any external .js node program file.</p>
  
  <ol>
  <li>Export method itself using <code>module.exports</code>:</li>
  </ol>
  
  <p>File Saved as Printer2.js</p>
  
  <pre><code>var printed = false;   
  function printNow() {
  console.log('= Print Started =');
  }    
  module.exports.printNow = printNow;
  </code></pre>
  
  <p>Then access <code>printNow()</code> by putting code <code>require('Printer2.js').printNow()</code> in any external .js node program file.</p>
  
  <p>Can anyone tell what is the difference and best way of doing it with respect to Node.js?</p>