title: What is the 'global' object in NodeJS
body: <p>I've just seen a weird behaviour of the <code>this</code> keyword in NodeJS environment. I'm listing them with code. I've run this codes with <code>NodeJS v6.x</code>, with a single <code>JavaScript</code> file.</p>
  
  <p>While testing with one line of code as follows, whether with or without the <code>'use strict'</code> statement, this points to an empty object <code>{}</code>.</p>
  
  <pre><code>console.log(this)
  </code></pre>
  
  <p>But, when I'm running the statement within a self executing function like,</p>
  
  <pre><code>(function(){
    console.log(this);
  }());
  </code></pre>
  
  <p>It's printing a really big object. Seems to me the Global execution context object created by <code>NodeJS</code> environment.</p>
  
  <p>And while executing the above function with a <code>'use strict'</code> statement, expectedly it's printing <code>undefined</code></p>
  
  <pre><code>(function(){
    'use strict';
  
    console.log(this);
  }());
  </code></pre>
  
  <p>But, while working with browser (I've tested only with <code>Chrome</code>), the first three examples yield the <code>window</code> object and the last one gave <code>undefined</code> as expected.</p>
  
  <p>The behaviour of the browser is quite understandable. But, in case of <code>NodeJS</code>, does it not create the execution context, until I'm wrapping inside a function? </p>
  
  <p>So, most of the code in <code>NodeJS</code> runs with an empty <strong>global</strong> <code>object</code>?</p>