title: `this` in global context and inside function
body: <p>According to <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this">this explanation in MDN</a>:</p>
  
  <ul>
  <li>in the global context, <code>this</code> refers to the global object</li>
  <li>in the function context, if the function is called directly, it again refers to the global object</li>
  </ul>
  
  <p>Yet, the following:</p>
  
  <pre><code>var globalThis = this;
  function a() {
      console.log(typeof this);
      console.log(typeof globalThis);
      console.log('is this the global object? '+(globalThis===this));
  }
  
  a();
  </code></pre>
  
  <p>... placed in file <code>foo.js</code> produces:</p>
  
  <pre><code>$ nodejs foo.js 
  object
  object
  is this the global object? false
  </code></pre>