Hacker News new | past | comments | ask | show | jobs | submit login

Lambda expressions which capture "this" have replaced almost all the cases when I'd use .bind in the past, the only time I've needed to do something like that recently has been when attaching events to the window object which need to be detached later - and come to think of it, writing a wrapper around that which just returns an object with a .detach() method would remove that use-case too.

Something like,

    this.handler = new Handler(window, "mouseup", () => this.whatever());
    
    // later...
    this.handler.detach();
YMMV though.



Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: