title: Globals in nodejs
body: <p>I've seen that people freak out when someone uses global variables in PHP.</p>
  
  <p>Are they just as bad in nodejs?</p>
  
  <p>Here's an example:</p>
  
  <pre><code>function my_app(){
      // ....
  }    
  
  my_app.prototype = {
    method_1: function(){
        // .......
    }
  }
  
  var my = my_app();
  </code></pre>
  
  <p>so <code>my</code> is global now. And I can use it in other classes that I define below without having to pass it to the constructor. I'm not even sure that it's called constructor in javascript :|</p>
  
  <p>But this seems natural to me. It's basically the same way ppl access outside variables from functions defined inside functions, right?</p>
  
  <p>in PHP this would look like:</p>
  
  <pre><code>&lt;?php
  
  class my_app{
  ..............
  }
  
  $my = new my_app();
  </code></pre>
  
  <p>Here $my has to be declared with the global keyword to be available inside functions or classes, but other than that it's the same thing</p>