You are reading a single comment by @tve and its replies. Click here to read the full conversation.
  • Tweaking the code some more, the doone call works fine, the dofoo call crashes:

    function x(a) {
      this.a = a;
    }
    var goo = new x("hello");
    
    x.prototype.foo = function(a, b) { console.log("foo", this.a, a, b); };
    
    setTimeout(function() {
      doone = goo.foo.bind(goo);
      doone(60, 12);
    }, 1000);
    
    setTimeout(function() {
      dofoo = goo.foo.bind(goo, 55);
      dofoo(10);
    }, 2000);
    
About

Avatar for tve @tve started