Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I guess the function could still be anonymous, but you will at least need to keep it assigned to some variable or property name. If you make use of the `handleEvent` pattern that @carussell suggested, you can however avoid having to keep track of all these callback functions since the listener can always be removed by passing `this` a second time:

['click', 'focus', 'blur'].forEach(type => elm.removeEventListener(type, this));



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

Search: