Bound instance-function vending (was RE: Arrow binding)

Domenic Denicola domenic at domenicdenicola.com
Mon Apr 23 09:47:47 PDT 2012


> Having done this dance a couple of times, let me suggest to you that the method form will *eventually* end up at a per-class getter on the prototype which vends an instance function which is bound. People will (reasonably) want binding of some sort.

This sounds lovely. I vaguely remember seeing it on es-discuss in the past (for one of the built-ins or proposed built-ins, maybe?). But never in the wild.

I'm curious, though---what advantages does this have over simply setting the method as an instance property? I.e. how does it differ from the following pattern?

function C() {
    var that = this;
    that.method = function () {
        console.log(that);
    };
}


More information about the es-discuss mailing list