title: Meaning of "this" in node.js modules and functions
body: <p>I have a JavaScript file which is loaded by <code>require</code>.</p>
  
  <pre><code>// loaded by require()
  
  var a = this; // "this" is an empty object
  this.anObject = {name:"An object"};
  
  var aFunction = function() {
      var innerThis = this; // "this" is node global object
  };
  
  aFunction();
  
  (function(anyParameter){
      console.log(anyParameter.anObject);
  })(
      this // "this" is same having anObject. Not "global"
  );
  </code></pre>
  
  <p>My question is: <code>this</code> in var <code>a = this;</code> is an empty object whereas <code>this</code> statements in functions are shadows of node.js global object. I know <code>this</code> keyword is different in functions but I could not understand why first <code>this</code> is not equal to global and <code>this</code> in functions equals to global.</p>
  
  <p>How does node.js inject <code>global</code> to <code>this</code> in function scopes, and why it does not inject it to the module scope?</p>