The code snippet says it all. I have a class and declare its variable in its constructor. The variable works fine inside the constructor, and when i make a new instance of the class, but the variable appears undefiend in the eventHandler.
"use strict";
class InputEngine{
__mouseDown(event){
alert(this.mouse); //doesn't work here
};
constructor(){
this.mouse =3;
window.addEventListener( 'mousedown', this.__mouseDown );
}
}
let a = new InputEngine();
alert(a.mouse); //works here
<!DOCTYPE html>
<html>
<body>
<p>Click your mouse.</p>
</body>
</html>