News for hackers. Stuff that matters.
Re:‘This’ in JavaScript by wiredearp on Thursday August 03, 2017 @12:37PM (#14921084)
If you plan to remove that event listener later on, you would need to go full verbose.

  this._callback = this.handleMouseDown.bind(this);
  elm.addEventListener('mousedown', this._callback);
  elm.removeEventListener('mousedown', this._callback);
  this._callback = null;
Compared to:

  elm.addEventListener('mousedown', this);
  elm.removeEventListener('mousedown', this);
  
@richthegeek I removed that event listener in my example to illustrate how easy it is, there was otherwise no good reason for it.

There are no comments on this comment yet.