title: Class loses "this" scope when calling prototype functions by reference
body: <p>Can anyone explain to me why "b" returns undefined and how I can get around this problem? Why does the "this" scope get lost when I call prototype functions by reference?</p>
  
  <pre><code>MyClass = function(test) {
  this.test = test;
  }
  
  MyClass.prototype.myfunc = function() {       
     return this.test;
  }
  
  var a = new MyClass('asd').myfunc();
  var b = new MyClass('asd').myfunc;
  
  // Returns "asd" correctly
  console.log(a)
  
  // Returns undefined??
  console.log(b())
  </code></pre>
  
  <p><em>=== EDIT / SOLUTION ===</em></p>
  
  <p>As plalx writes, the correct solution in my case is to use .bind(). So the result looks like this:</p>
  
  <pre><code>MyClass = function(test) {
      this.test = test;
  }
  
  MyClass.prototype.myfunc = function() {       
     return this.test;
  }
  
  var a = new MyClass('asd').myfunc();
  var b = new MyClass('asd'),
      bfunc = b.myfunc.bind(b)
  
  // Returns "asd" correctly
  console.log(a)
  
  // Also returns "asd" correctly!
  console.log(bfunc())
  </code></pre>