Hello!
I want to assign listeners when creating an object:
class ListenerClass{ constructor(){ document.addEvetListener('mousedown', function(event){ this.consoleCoordinate(event); }) } consoleCoordinate(event){ console.log('x:' + event.clientX); } } At the exit with every click I get an error that consoleCoordinate is not a function. Of course, because this in this.consoleCoordinate relevant to the context of addEventListener .
It's clear...
The question is - how do you pass this method to addEventListener in the constructor now?