title: Why does the 'this' in the prototype refer to the global context while the 'this' in the declaration refers to the function?
body: <p>Why does the <code>this</code> in the prototype refer to the global context while the <code>this</code> in the declaration refers to the function? Even when trying to explicitly set the context of <code>this</code> it still refers to the global context.</p>
  <pre><code>var Foo = function (a) {
    console.log(this); // this will refer to global context
    this.bar = () =&gt; {
      // this refers to function context
      return a;
    };
  };
  
  
  Foo.prototype = {
    biz: () =&gt; {
      return this.bar(); // this this will refer to global context
    },
  };
  
  var f = new Foo(7);
  f.biz(); // this.bar is not a function
  f.biz.call(f); // this.bar is not a function
  </code></pre>