Hacker News new | ask | show | jobs
by timruffles 5032 days ago
I can't see how the compiled code for Type is supposed to work?

If you deference a JS function from an object, you lose the context of `this`. So in

    Ruby.prototype.cut = function () {
      this.shape(); this.polish();
    };

    var old = Ruby.prototype.cut;

    Ruby.prototype.cut = function () {
      old(); this.engrave();
    };
`Ruby.prototype.cut` will be called with `window` as `this`, so `this.shape` will be undefined. Use `old.call(this)` to get the behaviour you want.
1 comments

You're right. I knew I'd miss something! Thanks for catching my mistake.